MCPcopy Create free account
hub / github.com/flant/shell-operator / TestTaskStorage_DeleteFunc

Function TestTaskStorage_DeleteFunc

pkg/task/queue/task_storage_test.go:151–182  ·  view source on GitHub ↗

TestTaskStorage_DeleteFunc tests the DeleteFunc operation

(t *testing.T)

Source from the content-addressed store, hash-verified

149
150// TestTaskStorage_DeleteFunc tests the DeleteFunc operation
151func TestTaskStorage_DeleteFunc(t *testing.T) {
152 ts := newTaskStorage()
153
154 task1 := task.NewTask("test1")
155 task2 := task.NewTask("test2")
156 task3 := task.NewTask("test3")
157
158 ts.AddLast(task1, task2, task3)
159
160 // Delete tasks where Type is not "test2"
161 ts.DeleteFunc(func(t task.Task) bool {
162 return t.GetType() != "test2"
163 })
164
165 if ts.Length() != 2 {
166 t.Errorf("Expected length 2 after DeleteFunc, got %d", ts.Length())
167 }
168
169 snapshot := ts.GetSnapshot()
170 if snapshot[0] != task1 || snapshot[1] != task3 {
171 t.Error("DeleteFunc failed: incorrect remaining tasks")
172 }
173
174 // Test DeleteFunc that deletes all
175 ts.DeleteFunc(func(t task.Task) bool {
176 return false
177 })
178
179 if ts.Length() != 0 {
180 t.Errorf("Expected length 0 after deleting all, got %d", ts.Length())
181 }
182}
183
184// TestTaskStorage_ProcessResult tests the ProcessResult operation
185func TestTaskStorage_ProcessResult(t *testing.T) {

Callers

nothing calls this directly

Calls 8

NewTaskFunction · 0.92
newTaskStorageFunction · 0.85
AddLastMethod · 0.65
GetTypeMethod · 0.65
DeleteFuncMethod · 0.45
LengthMethod · 0.45
GetSnapshotMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected