a8078f787c
Add Status field (gorm, indexed, default active) to both User and File models. Add User status constants: StatusActive, StatusAdminDeleted. Add File status constant: StatusUserDeleted. Add tests verifying Status field is excluded from JSON serialization. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
30 lines
525 B
Go
30 lines
525 B
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestUserJSONOmitsStatusField(t *testing.T) {
|
|
u := User{
|
|
ID: "user-1",
|
|
Username: "alice",
|
|
Email: "alice@example.com",
|
|
Status: StatusActive,
|
|
}
|
|
|
|
raw, err := json.Marshal(u)
|
|
if err != nil {
|
|
t.Fatalf("json.Marshal: %v", err)
|
|
}
|
|
|
|
var m map[string]interface{}
|
|
if err := json.Unmarshal(raw, &m); err != nil {
|
|
t.Fatalf("json.Unmarshal: %v", err)
|
|
}
|
|
|
|
if _, ok := m["status"]; ok {
|
|
t.Error("Status field should not appear in JSON output")
|
|
}
|
|
}
|