MCPcopy
hub / github.com/riverqueue/river / Test_JobListCursor_MarshalJSON

Function Test_JobListCursor_MarshalJSON

job_list_params_test.go:150–189  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func Test_JobListCursor_MarshalJSON(t *testing.T) {
151 t.Parallel()
152
153 t.Run("CanMarshalAndUnmarshal", func(t *testing.T) {
154 t.Parallel()
155
156 now := time.Now().UTC()
157 cursor := &JobListCursor{
158 id: 4,
159 kind: "test_kind",
160 queue: "test_queue",
161 time: now,
162 }
163
164 text, err := json.Marshal(cursor)
165 require.NoError(t, err)
166 require.NotEmpty(t, text)
167
168 unmarshaledParams := &JobListCursor{}
169 require.NoError(t, json.Unmarshal(text, unmarshaledParams))
170
171 require.Equal(t, cursor, unmarshaledParams)
172 })
173
174 t.Run("ErrorsOnJobOnlyCursor", func(t *testing.T) {
175 t.Parallel()
176
177 jobRow := &rivertype.JobRow{
178 ID: 4,
179 Kind: "test",
180 Queue: "test",
181 State: rivertype.JobStateRunning,
182 }
183
184 cursor := JobListCursorFromJob(jobRow)
185
186 _, err := json.Marshal(cursor)
187 require.EqualError(t, err, "json: error calling MarshalText for type *river.JobListCursor: cursor initialized with only a job can't be marshaled; try a cursor from JobListResult instead")
188 })
189}

Callers

nothing calls this directly

Calls 3

JobListCursorFromJobFunction · 0.85
RunMethod · 0.65
NowMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…