(t *testing.T)
| 148 | } |
| 149 | |
| 150 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…