diff options
Diffstat (limited to 'internal/resource/resource_test.go')
| -rw-r--r-- | internal/resource/resource_test.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/internal/resource/resource_test.go b/internal/resource/resource_test.go index 947f0ac..8741f2a 100644 --- a/internal/resource/resource_test.go +++ b/internal/resource/resource_test.go @@ -6,7 +6,7 @@ import ( func TestResourceID(t *testing.T) { resetRepository() - res := Register("File", "/tmp/foo.txt") + res := Register("File", "/tmp/foo.txt", &mockApplier{}) expected := "File[/tmp/foo.txt]" if res.ID() != expected { t.Errorf("expected ID %s, got %s", expected, res.ID()) @@ -15,7 +15,7 @@ func TestResourceID(t *testing.T) { func TestResourceString(t *testing.T) { resetRepository() - res := Register("File", "/tmp/foo.txt") + res := Register("File", "/tmp/foo.txt", &mockApplier{}) expected := "File[/tmp/foo.txt]" if res.String() != expected { t.Errorf("expected String %s, got %s", expected, res.String()) @@ -26,7 +26,7 @@ func TestNew(t *testing.T) { resetRepository() type_ := "File" name := "/tmp/foo.txt" - res := Register(type_, name) + res := Register(type_, name, &mockApplier{}) if res.Type != type_ { t.Errorf("expected type %s, got %s", type_, res.Type) @@ -42,7 +42,7 @@ func TestNew(t *testing.T) { func TestRepositoryRegister(t *testing.T) { resetRepository() repo := getRepository() - res := Register("File", "/tmp/foo.txt") + res := Register("File", "/tmp/foo.txt", &mockApplier{}) // First registration already happened in New() // But we can try to register again via the repository directly @@ -51,8 +51,12 @@ func TestRepositoryRegister(t *testing.T) { } // Registration of a different resource should succeed - res2 := Register("File", "/tmp/bar.txt") + res2 := Register("File", "/tmp/bar.txt", &mockApplier{}) if err := repo.register(res2); err == nil { t.Error("expected error when registering the same resource twice, got nil") } } + +type mockApplier struct{} + +func (m *mockApplier) Apply() error { return nil } |
