summaryrefslogtreecommitdiff
path: root/internal/resource/resource_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-07-05 11:10:10 +0300
committerPaul Buetow <paul@buetow.org>2026-07-05 11:10:10 +0300
commit5256a4d1e5a56510758bfac710ba2ad2a45af66e (patch)
treebff875458182a308979a575a78a26e61ff248a05 /internal/resource/resource_test.go
parent6cf5e1bf6e8f1551cf215bf838c27ec8281cf045 (diff)
initial Apply
Diffstat (limited to 'internal/resource/resource_test.go')
-rw-r--r--internal/resource/resource_test.go14
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 }