MCPcopy Create free account
hub / github.com/compozy/agh / TestKernelPutRawUpdateDeleteAndNotFound

Function TestKernelPutRawUpdateDeleteAndNotFound

internal/resources/kernel_test.go:54–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestKernelPutRawUpdateDeleteAndNotFound(t *testing.T) {
55 t.Parallel()
56
57 kernel, _ := openTestKernel(t)
58 ctx := testutil.Context(t)
59 actor := testDaemonActor()
60
61 record, err := kernel.PutRaw(ctx, actor, RawDraft{
62 Kind: testResourceKind,
63 ID: "tool-updatable",
64 Scope: ResourceScope{Kind: ResourceScopeKindGlobal},
65 ExpectedVersion: 0,
66 SpecJSON: []byte(`{"name":"alpha"}`),
67 })
68 if err != nil {
69 t.Fatalf("PutRaw(create) error = %v", err)
70 }
71
72 updated, err := kernel.PutRaw(ctx, actor, RawDraft{
73 Kind: testResourceKind,
74 ID: "tool-updatable",
75 Scope: ResourceScope{Kind: ResourceScopeKindWorkspace, ID: "ws-1"},
76 ExpectedVersion: record.Version,
77 SpecJSON: []byte(`{"name":"beta"}`),
78 })
79 if err != nil {
80 t.Fatalf("PutRaw(update) error = %v", err)
81 }
82 if got, want := updated.Version, int64(2); got != want {
83 t.Fatalf("updated.Version = %d, want %d", got, want)
84 }
85 if got, want := updated.Scope, (ResourceScope{Kind: ResourceScopeKindWorkspace, ID: "ws-1"}); got != want {
86 t.Fatalf("updated.Scope = %#v, want %#v", got, want)
87 }
88
89 if err := kernel.DeleteRaw(ctx, actor, testResourceKind, "tool-updatable", updated.Version); err != nil {
90 t.Fatalf("DeleteRaw() error = %v", err)
91 }
92
93 if _, err := kernel.GetRaw(ctx, actor, testResourceKind, "tool-updatable"); !errors.Is(err, ErrNotFound) {
94 t.Fatalf("GetRaw(after delete) error = %v, want ErrNotFound", err)
95 }
96}
97
98func TestKernelWriteTransactionsRetryBusyLocks(t *testing.T) {
99 t.Run("Should retry PutRaw until the competing write lock is released", func(t *testing.T) {

Callers

nothing calls this directly

Calls 7

ContextFunction · 0.92
openTestKernelFunction · 0.85
testDaemonActorFunction · 0.85
PutRawMethod · 0.65
DeleteRawMethod · 0.65
GetRawMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected