package applystatus import ( "context" "testing" "github.com/samcharles93/archie-core/internal/domain/org" "github.com/samcharles93/archie-core/internal/domain/storecontract" ) type recordingStore struct{ put []storecontract.ApplyStatus } func (s *recordingStore) PutApplyStatus(_ context.Context, status storecontract.ApplyStatus) error { s.put = append(s.put, status) return nil } func (s *recordingStore) ListApplyStatus(context.Context) ([]storecontract.ApplyStatus, error) { return s.put, nil } // A read made for another org must not overwrite the instance's own record. func TestReportKeepsToTheInstanceCopy(t *testing.T) { tests := []struct { name string org org.OrgID want int }{ {"no org", "", 1}, {"system org", org.DefaultOrgID, 1}, {"other org", "org-acme", 0}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { store := &recordingStore{} New(Daemon, store, nil).Report(org.WithOrg(context.Background(), tt.org), "workflow-definitions", 3, nil) if len(store.put) != tt.want { t.Fatalf("records written = %d, want %d", len(store.put), tt.want) } }) } }