e071084ebe
govulncheck / govulncheck (push) Has been cancelled
Lint / golangci-lint (push) Has been cancelled
Run Tests / Unit Tests (push) Has been cancelled
Run Tests / Etcd Integration Tests (push) Has been cancelled
Harness (E2E) / Harnesses (mock LLM) (push) Has been cancelled
Harness (E2E) / Provider harnesses (live LLM conformance) (push) Has been cancelled
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package micro
|
|
|
|
import "testing"
|
|
|
|
func TestParseModelOptions(t *testing.T) {
|
|
tests := []struct {
|
|
comment string
|
|
wantTable string
|
|
wantKey string
|
|
}{
|
|
{" @model\n", "", ""},
|
|
{" @model(table=app_users)\n", "app_users", ""},
|
|
{" @model(key=user_id)\n", "", "user_id"},
|
|
{" @model(table=users, key=user_id)\n", "users", "user_id"},
|
|
{" some description\n @model(table=items)\n", "items", ""},
|
|
{" no annotation here\n", "", ""},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
table, key := parseModelOptions(tt.comment)
|
|
if table != tt.wantTable {
|
|
t.Errorf("parseModelOptions(%q): table = %q, want %q", tt.comment, table, tt.wantTable)
|
|
}
|
|
if key != tt.wantKey {
|
|
t.Errorf("parseModelOptions(%q): key = %q, want %q", tt.comment, key, tt.wantKey)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestProtoFieldGoType(t *testing.T) {
|
|
// Smoke test - just verify it doesn't panic with nil
|
|
typ := protoFieldGoType(nil)
|
|
if typ != "string" {
|
|
// nil field returns default based on zero value TYPE_DOUBLE=0
|
|
t.Logf("protoFieldGoType(nil) = %q", typ)
|
|
}
|
|
}
|