feat(go-config): multi-format codecs, envc CLI, fixtures, ASRs
- Module github.com/eslider/go-config with env/yaml/json/ini packages - internal: source, keymap, merge, structconv, bytesutil - cmd/envc: convert, get, merge - docs/asr ASR-0001..0008, README/CHANGELOG/AGENTS refresh - golangci-lint v2 config; tests + fixtures Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
package env
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNestedFromFlat(t *testing.T) {
|
||||
got := nestedFromFlat(map[string]string{
|
||||
"FOO": "bar",
|
||||
"SERVICE_HTTP_PORT": "8080",
|
||||
"SERVICE_KEY": "abc",
|
||||
}, "")
|
||||
want := map[string]any{
|
||||
"foo": "bar",
|
||||
"service": map[string]any{
|
||||
"http": map[string]any{"port": "8080"},
|
||||
"key": "abc",
|
||||
},
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("got %#v want %#v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNestedFromFlat_FirstWriteWins(t *testing.T) {
|
||||
flat := map[string]string{}
|
||||
flat["A"] = "1"
|
||||
got := nestedFromFlat(flat, "")
|
||||
// Second insert for same key is ignored by insertPath within one build.
|
||||
insertPath(got, []string{"a"}, "2")
|
||||
if got["a"] != "1" {
|
||||
t.Fatalf("got %v", got["a"])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user