caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

96 lines
1.9 KiB
Go

package storage
import (
"encoding/json"
"testing"
)
func TestNormalizeMetadataValue(t *testing.T) {
tests := []struct {
name string
input interface{}
want string
wantErr bool
}{
{
name: "string input",
input: `{"key":"value"}`,
want: `{"key":"value"}`,
wantErr: false,
},
{
name: "[]byte input",
input: []byte(`{"key":"value"}`),
want: `{"key":"value"}`,
wantErr: false,
},
{
name: "json.RawMessage input",
input: json.RawMessage(`{"key":"value"}`),
want: `{"key":"value"}`,
wantErr: false,
},
{
name: "empty object string",
input: `{}`,
want: `{}`,
wantErr: false,
},
{
name: "empty object []byte",
input: []byte(`{}`),
want: `{}`,
wantErr: false,
},
{
name: "complex JSON",
input: `{"files":["foo.go","bar.go"],"tool":"linter@1.0"}`,
want: `{"files":["foo.go","bar.go"],"tool":"linter@1.0"}`,
wantErr: false,
},
{
name: "invalid JSON string",
input: `{invalid}`,
wantErr: true,
},
{
name: "invalid JSON []byte",
input: []byte(`not json`),
wantErr: true,
},
{
name: "invalid JSON json.RawMessage",
input: json.RawMessage(`{broken`),
wantErr: true,
},
{
name: "unsupported type int",
input: 123,
wantErr: true,
},
{
name: "unsupported type map",
input: map[string]string{"key": "value"},
wantErr: true,
},
{
name: "unsupported type struct",
input: struct{ Key string }{Key: "value"},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := NormalizeMetadataValue(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("NormalizeMetadataValue() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !tt.wantErr && got != tt.want {
t.Errorf("NormalizeMetadataValue() = %v, want %v", got, tt.want)
}
})
}
}