github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/dashboard/app/entities_test.go (about)

     1  // Copyright 2023 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package main
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/google/go-cmp/cmp"
    10  	db "google.golang.org/appengine/v2/datastore"
    11  )
    12  
    13  func TestOldBugTagsConversion(t *testing.T) {
    14  	oldBug := &struct {
    15  		Namespace string
    16  		Title     string
    17  		Tags      BugTags202304
    18  	}{
    19  		Namespace: "some-ns",
    20  		Title:     "some title",
    21  		Tags: BugTags202304{
    22  			Subsystems: []BugTag202304{
    23  				{
    24  					Name:  "first",
    25  					SetBy: "user",
    26  				},
    27  				{
    28  					Name: "second",
    29  				},
    30  			},
    31  		},
    32  	}
    33  
    34  	fields, err := db.SaveStruct(oldBug)
    35  	if err != nil {
    36  		t.Fatal(err)
    37  	}
    38  
    39  	newBug := &Bug{}
    40  	err = newBug.Load(fields)
    41  	if err != nil {
    42  		t.Fatal(err)
    43  	}
    44  
    45  	if diff := cmp.Diff(&Bug{
    46  		Namespace: "some-ns",
    47  		Title:     "some title",
    48  		Labels: []BugLabel{
    49  			{
    50  				Value: "first",
    51  				SetBy: "user",
    52  				Label: SubsystemLabel,
    53  			},
    54  			{
    55  				Value: "second",
    56  				Label: SubsystemLabel,
    57  			},
    58  		},
    59  	}, newBug); diff != "" {
    60  		t.Fatal(diff)
    61  	}
    62  }