@@ -181,6 +181,61 @@ func TestAPI_compareRecordEcosystemMeta(t *testing.T) {
181181 })
182182}
183183
184+ func TestAPI_compareRecordUpdateJobWarning (t * testing.T ) {
185+ t .Run ("matching warning" , func (t * testing.T ) {
186+ warning := model.RecordUpdateJobWarning {
187+ WarnType : "warn_once" ,
188+ WarnTitle : "something to know" ,
189+ WarnDescription : "more details here" ,
190+ }
191+ if err := compareRecordUpdateJobWarning (warning , warning ); err != nil {
192+ t .Errorf ("expected no error, got %v" , err )
193+ }
194+ })
195+
196+ t .Run ("mismatched warning" , func (t * testing.T ) {
197+ expect := model.RecordUpdateJobWarning {WarnType : "warn_once" , WarnTitle : "title-a" , WarnDescription : "desc-a" }
198+ actual := model.RecordUpdateJobWarning {WarnType : "warn_once" , WarnTitle : "title-b" , WarnDescription : "desc-b" }
199+ if err := compareRecordUpdateJobWarning (expect , actual ); err == nil {
200+ t .Error ("expected error for mismatched warning" )
201+ }
202+ })
203+
204+ t .Run ("compare via compare function" , func (t * testing.T ) {
205+ warning := model.RecordUpdateJobWarning {
206+ WarnType : "warn_once" ,
207+ WarnTitle : "something to know" ,
208+ WarnDescription : "more details here" ,
209+ }
210+ expectWrapper := & model.UpdateWrapper {Data : warning }
211+ actualWrapper := & model.UpdateWrapper {Data : warning }
212+ if err := compare (expectWrapper , actualWrapper ); err != nil {
213+ t .Errorf ("expected no error from compare, got %v" , err )
214+ }
215+ })
216+
217+ t .Run ("decodeWrapper round-trip" , func (t * testing.T ) {
218+ payload := []byte (`{"data": {"warn-type": "warn_once", "warn-title": "something to know", "warn-description": "more details here"}}` )
219+ wrapper , err := decodeWrapper ("record_update_job_warning" , payload )
220+ if err != nil {
221+ t .Fatalf ("unexpected decode error: %v" , err )
222+ }
223+ warning , ok := wrapper .Data .(model.RecordUpdateJobWarning )
224+ if ! ok {
225+ t .Fatalf ("expected RecordUpdateJobWarning, got %T" , wrapper .Data )
226+ }
227+ if warning .WarnType != "warn_once" {
228+ t .Errorf ("expected warn-type 'warn_once', got '%s'" , warning .WarnType )
229+ }
230+ if warning .WarnTitle != "something to know" {
231+ t .Errorf ("expected warn-title 'something to know', got '%s'" , warning .WarnTitle )
232+ }
233+ if warning .WarnDescription != "more details here" {
234+ t .Errorf ("expected warn-description 'more details here', got '%s'" , warning .WarnDescription )
235+ }
236+ })
237+ }
238+
184239func TestAPI_compareDependencySubmissionRequest (t * testing.T ) {
185240 t .Run ("ignores detector version" , func (t * testing.T ) {
186241 expect := model.DependencySubmissionRequest {
0 commit comments