Fix buildQuery test calls to include inverseMatch argument

This commit is contained in:
2026-03-25 15:07:27 +11:00
parent e18fa8e4f3
commit 547333ecd2
3 changed files with 37 additions and 31 deletions
+6 -6
View File
@@ -36,42 +36,42 @@ func rawJSON(v interface{}) json.RawMessage {
// ---- buildQuery -------------------------------------------------------------
func TestBuildQuery_NoFilters(t *testing.T) {
q := buildQuery("", "", "", "", "enc_role", false)
q := buildQuery("", "", "", "", "", "enc_role", false)
if !strings.Contains(q, "enc_role") {
t.Fatalf("expected default role query, got %s", q)
}
}
func TestBuildQuery_Node(t *testing.T) {
q := buildQuery("host1", "", "", "", "enc_role", false)
q := buildQuery("host1", "", "", "", "", "enc_role", false)
if !strings.Contains(q, "certname") || !strings.Contains(q, "host1") {
t.Fatalf("unexpected query: %s", q)
}
}
func TestBuildQuery_FactAndMatch(t *testing.T) {
q := buildQuery("", "region", "syd1", "", "enc_role", false)
q := buildQuery("", "region", "syd1", "", "", "enc_role", false)
if !strings.Contains(q, "region") || !strings.Contains(q, "syd1") {
t.Fatalf("unexpected query: %s", q)
}
}
func TestBuildQuery_PartialMatch(t *testing.T) {
q := buildQuery("", "enc_role", "", "dns", "enc_role", false)
q := buildQuery("", "enc_role", "", "dns", "", "enc_role", false)
if !strings.Contains(q, "~") || !strings.Contains(q, "dns") {
t.Fatalf("expected partial match query, got %s", q)
}
}
func TestBuildQuery_ShowRole(t *testing.T) {
q := buildQuery("", "", "", "", "my_role_fact", true)
q := buildQuery("", "", "", "", "", "my_role_fact", true)
if !strings.Contains(q, "my_role_fact") {
t.Fatalf("expected role fact in query, got %s", q)
}
}
func TestBuildQuery_CustomRoleFact(t *testing.T) {
q := buildQuery("", "", "", "", "custom_role", true)
q := buildQuery("", "", "", "", "", "custom_role", true)
if !strings.Contains(q, "custom_role") {
t.Fatalf("expected custom role fact, got %s", q)
}