(t *testing.T)
| 35 | } |
| 36 | |
| 37 | func TestIsAuthenticated(t *testing.T) { |
| 38 | server := httptest.NewServer(http.NotFoundHandler()) |
| 39 | defer server.Close() |
| 40 | |
| 41 | t.Run("with_HEY_TOKEN", func(t *testing.T) { |
| 42 | t.Setenv("HEY_TOKEN", "tok") |
| 43 | mgr := testManager(t, server) |
| 44 | if !mgr.IsAuthenticated() { |
| 45 | t.Error("expected authenticated with HEY_TOKEN set") |
| 46 | } |
| 47 | }) |
| 48 | |
| 49 | t.Run("with_stored_token", func(t *testing.T) { |
| 50 | t.Setenv("HEY_TOKEN", "") |
| 51 | mgr := testManager(t, server) |
| 52 | if err := mgr.LoginWithToken("stored-tok"); err != nil { |
| 53 | t.Fatalf("LoginWithToken: %v", err) |
| 54 | } |
| 55 | if !mgr.IsAuthenticated() { |
| 56 | t.Error("expected authenticated with stored token") |
| 57 | } |
| 58 | }) |
| 59 | |
| 60 | t.Run("unauthenticated", func(t *testing.T) { |
| 61 | t.Setenv("HEY_TOKEN", "") |
| 62 | mgr := testManager(t, server) |
| 63 | if mgr.IsAuthenticated() { |
| 64 | t.Error("expected not authenticated with no credentials") |
| 65 | } |
| 66 | }) |
| 67 | } |
| 68 | |
| 69 | func TestNormalizeBaseURL(t *testing.T) { |
| 70 | tests := []struct { |
nothing calls this directly
no test coverage detected