X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm%2Fsync_test.go;h=8cde5ab612e7d6aeaf967ee01943fea4ddc06c8f;hb=8620dac1f9ee7f73058e3e97b488ec0c710a89df;hp=4616f716a28d75f5967e3654b02f2ede81331c84;hpb=3473766d8afb07cb0685694656947883cbbd1138;p=safcm%2Fsafcm.git diff --git a/cmd/safcm/sync_test.go b/cmd/safcm/sync_test.go index 4616f71..8cde5ab 100644 --- a/cmd/safcm/sync_test.go +++ b/cmd/safcm/sync_test.go @@ -40,6 +40,12 @@ func TestHostsToSync(t *testing.T) { t.Fatal(err) } + const errMsg = ` + +Groups depending on "detected" groups cannot be used to select hosts as these +are only available after the hosts were contacted. +` + tests := []struct { name string names []string @@ -100,7 +106,7 @@ func TestHostsToSync(t *testing.T) { { "group: single name", - []string{"group"}, + []string{"group3"}, []*config.Host{ allHosts.Map["host1.example.org"], }, @@ -108,7 +114,7 @@ func TestHostsToSync(t *testing.T) { }, { "group: multiple names", - []string{"group", "group2"}, + []string{"group3", "group2"}, []*config.Host{ allHosts.Map["host1.example.org"], allHosts.Map["host2"], @@ -117,7 +123,7 @@ func TestHostsToSync(t *testing.T) { }, { "group: multiple identical names", - []string{"group", "group2", "group"}, + []string{"group3", "group2", "group3"}, []*config.Host{ allHosts.Map["host1.example.org"], allHosts.Map["host2"], @@ -126,7 +132,7 @@ func TestHostsToSync(t *testing.T) { }, { "group: multiple names, including unknown", - []string{"group", "group2", "unknown-group"}, + []string{"group3", "group2", "unknown-group"}, nil, fmt.Errorf("hosts/groups not found: \"unknown-group\""), }, @@ -141,6 +147,19 @@ func TestHostsToSync(t *testing.T) { nil, }, + { + "group: single name (detected)", + []string{"group"}, + nil, + fmt.Errorf(`group "group" depends on "detected" groups` + errMsg), + }, + { + "group: multiple names (detected)", + []string{"group", "group2"}, + nil, + fmt.Errorf(`group "group" depends on "detected" groups` + errMsg), + }, + { "\"all\" and name", []string{"all", "group2"},