| 1 | package moves |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | // A move compares the instance key like any instance variable: a target |
| 6 | // that would start with a different key, or none, is a difference the |
| 7 | // launch check reports, never a note (L21). |
| 8 | func TestEnvReportComparesTheInstanceKey(t *testing.T) { |
| 9 | const name = "CARLOS_INSTANCE_KEY" |
| 10 | if got := Class(name); got != "equal" { |
| 11 | t.Fatalf("Class(%s) = %q, want equal", name, got) |
| 12 | } |
| 13 | key := []byte("0123456789abcdef0123456789abcdef") |
| 14 | src := ReportEnv(key, map[string]string{name: "a2V5LW9uZQ==", "CARLOS_REGION": "ie"}) |
| 15 | for _, tc := range []struct { |
| 16 | target map[string]string |
| 17 | want string |
| 18 | }{ |
| 19 | {map[string]string{name: "a2V5LXR3bw==", "CARLOS_REGION": "uk"}, "differs"}, |
| 20 | {map[string]string{"CARLOS_REGION": "uk"}, "missing"}, |
| 21 | } { |
| 22 | // The kind is the whole check: T3 (movesreport.go) fails on every |
| 23 | // kind but advisory-differs, which only an advisory variable gets. |
| 24 | diffs := CompareEnv(src, ReportEnv(key, tc.target), false, false) |
| 25 | if len(diffs) != 1 || diffs[0].Name != name || diffs[0].Kind != tc.want { |
| 26 | t.Fatalf("diffs = %+v, want one %s on %s", diffs, tc.want, name) |
| 27 | } |
| 28 | } |
| 29 | if diffs := CompareEnv(src, ReportEnv(key, map[string]string{name: "a2V5LW9uZQ==", "CARLOS_REGION": "uk"}), false, false); len(diffs) != 0 { |
| 30 | t.Fatalf("the same key reported a difference: %+v", diffs) |
| 31 | } |
| 32 | } |
| 33 | |