MCPcopy Index your code
hub / github.com/coder/coder / Test_diffValues

Function Test_diffValues

enterprise/audit/diff_internal_test.go:19–235  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func Test_diffValues(t *testing.T) {
20 t.Parallel()
21
22 t.Run("Normal", func(t *testing.T) {
23 t.Parallel()
24
25 type foo struct {
26 Bar string `json:"bar"`
27 Baz int `json:"baz"`
28 }
29
30 table := auditMap(map[any]map[string]Action{
31 &foo{}: {
32 "bar": ActionTrack,
33 "baz": ActionTrack,
34 },
35 })
36
37 runDiffValuesTests(t, table, []diffTest{
38 {
39 name: "LeftEmpty",
40 left: foo{Bar: "", Baz: 0}, right: foo{Bar: "bar", Baz: 10},
41 exp: audit.Map{
42 "bar": audit.OldNew{Old: "", New: "bar"},
43 "baz": audit.OldNew{Old: 0, New: 10},
44 },
45 },
46 {
47 name: "RightEmpty",
48 left: foo{Bar: "Bar", Baz: 10}, right: foo{Bar: "", Baz: 0},
49 exp: audit.Map{
50 "bar": audit.OldNew{Old: "Bar", New: ""},
51 "baz": audit.OldNew{Old: 10, New: 0},
52 },
53 },
54 {
55 name: "NoChange",
56 left: foo{Bar: "", Baz: 0}, right: foo{Bar: "", Baz: 0},
57 exp: audit.Map{},
58 },
59 {
60 name: "SingleFieldChange",
61 left: foo{Bar: "", Baz: 0}, right: foo{Bar: "Bar", Baz: 0},
62 exp: audit.Map{
63 "bar": audit.OldNew{Old: "", New: "Bar"},
64 },
65 },
66 })
67 })
68
69 t.Run("PointerField", func(t *testing.T) {
70 t.Parallel()
71
72 type foo struct {
73 Bar *string `json:"bar"`
74 }
75
76 table := auditMap(map[any]map[string]Action{

Callers

nothing calls this directly

Calls 4

RefFunction · 0.92
auditMapFunction · 0.85
runDiffValuesTestsFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected