(t *testing.T)
| 585 | } |
| 586 | |
| 587 | func TestParseEnvConfig(t *testing.T) { |
| 588 | t.Run("should error on unexpected fields", func(t *testing.T) { |
| 589 | _, err := parseEnvConfig(envTestUserPassConfig) |
| 590 | assert.ErrorContains(t, err, "json: unknown field \"username\"") |
| 591 | }) |
| 592 | t.Run("should be able to load env credentials", func(t *testing.T) { |
| 593 | got, err := parseEnvConfig(envTestAuthConfig) |
| 594 | assert.NilError(t, err) |
| 595 | expected := map[string]types.AuthConfig{ |
| 596 | "env.example.test": { |
| 597 | Username: "env_user", |
| 598 | Password: "env_pass", |
| 599 | ServerAddress: "env.example.test", |
| 600 | }, |
| 601 | } |
| 602 | assert.NilError(t, err) |
| 603 | assert.Check(t, is.DeepEqual(got, expected)) |
| 604 | }) |
| 605 | t.Run("should not support multiple JSON objects", func(t *testing.T) { |
| 606 | _, err := parseEnvConfig(`{"auths":{"env.example.test":{"auth":"something"}}}{}`) |
| 607 | assert.ErrorContains(t, err, "does not support more than one JSON object") |
| 608 | }) |
| 609 | } |
| 610 | |
| 611 | func TestSave(t *testing.T) { |
| 612 | configFile := New("test-save") |
nothing calls this directly
no test coverage detected
searching dependent graphs…