package moves import "testing" // A move compares the instance key like any instance variable: a target // that would start with a different key, or none, is a difference the // launch check reports, never a note (L21). func TestEnvReportComparesTheInstanceKey(t *testing.T) { const name = "CARLOS_INSTANCE_KEY" if got := Class(name); got != "equal" { t.Fatalf("Class(%s) = %q, want equal", name, got) } key := []byte("0123456789abcdef0123456789abcdef") src := ReportEnv(key, map[string]string{name: "a2V5LW9uZQ==", "CARLOS_REGION": "ie"}) for _, tc := range []struct { target map[string]string want string }{ {map[string]string{name: "a2V5LXR3bw==", "CARLOS_REGION": "uk"}, "differs"}, {map[string]string{"CARLOS_REGION": "uk"}, "missing"}, } { // The kind is the whole check: T3 (movesreport.go) fails on every // kind but advisory-differs, which only an advisory variable gets. diffs := CompareEnv(src, ReportEnv(key, tc.target), false, false) if len(diffs) != 1 || diffs[0].Name != name || diffs[0].Kind != tc.want { t.Fatalf("diffs = %+v, want one %s on %s", diffs, tc.want, name) } } if diffs := CompareEnv(src, ReportEnv(key, map[string]string{name: "a2V5LW9uZQ==", "CARLOS_REGION": "uk"}), false, false); len(diffs) != 0 { t.Fatalf("the same key reported a difference: %+v", diffs) } }