aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/fortee/fortee_test.go
blob: 90ae6257f55ed4681dd2c351ae1104a1cfea8533 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package fortee

import (
	"context"
	"net/http"
	"testing"
)

func TestAddAcceptHeader(t *testing.T) {
	req, err := http.NewRequest(http.MethodGet, "https://example.com", nil)
	if err != nil {
		t.Fatalf("failed to create request: %v", err)
	}

	if err := addAcceptHeader(context.Background(), req); err != nil {
		t.Fatalf("unexpected error: %v", err)
	}

	got := req.Header.Get("Accept")
	if got != "application/json" {
		t.Errorf("expected Accept header 'application/json', got %q", got)
	}
}

func TestEndpoint(t *testing.T) {
	if Endpoint != "https://fortee.jp" {
		t.Errorf("expected endpoint 'https://fortee.jp', got %q", Endpoint)
	}
}

func TestErrorValues(t *testing.T) {
	if ErrLoginFailed == nil {
		t.Error("ErrLoginFailed should not be nil")
	}
	if ErrUserNotFound == nil {
		t.Error("ErrUserNotFound should not be nil")
	}
	if ErrLoginFailed.Error() != "fortee login failed" {
		t.Errorf("unexpected error message: %q", ErrLoginFailed.Error())
	}
	if ErrUserNotFound.Error() != "fortee user not found" {
		t.Errorf("unexpected error message: %q", ErrUserNotFound.Error())
	}
}