43 lines
866 B
Go
43 lines
866 B
Go
package job
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"haixun-backend/internal/model/job/domain/entity"
|
|
)
|
|
|
|
func TestRunOwnedByTopLevelFields(t *testing.T) {
|
|
run := &entity.Run{
|
|
TenantID: "tenant-a",
|
|
OwnerUID: "user-1",
|
|
}
|
|
if !runOwnedBy(run, "tenant-a", "user-1") {
|
|
t.Fatal("expected top-level owner match")
|
|
}
|
|
if runOwnedBy(run, "tenant-a", "user-2") {
|
|
t.Fatal("expected different uid to be rejected")
|
|
}
|
|
}
|
|
|
|
func TestRunOwnedByPayloadFallback(t *testing.T) {
|
|
run := &entity.Run{
|
|
Payload: map[string]any{
|
|
"tenant_id": "tenant-a",
|
|
"owner_uid": "user-1",
|
|
},
|
|
}
|
|
if !runOwnedBy(run, "tenant-a", "user-1") {
|
|
t.Fatal("expected payload owner match")
|
|
}
|
|
}
|
|
|
|
func TestRunOwnedByUserScopeLegacy(t *testing.T) {
|
|
run := &entity.Run{
|
|
Scope: "user",
|
|
ScopeID: "user-1",
|
|
}
|
|
if !runOwnedBy(run, "tenant-a", "user-1") {
|
|
t.Fatal("expected legacy user scope match")
|
|
}
|
|
}
|