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