MCPcopy Create free account
hub / github.com/docker/cli / TestParseEnvConfig

Function TestParseEnvConfig

cli/config/configfile/file_test.go:587–609  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

585}
586
587func 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
611func TestSave(t *testing.T) {
612 configFile := New("test-save")

Callers

nothing calls this directly

Calls 1

parseEnvConfigFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…