37 lines
727 B
Go
37 lines
727 B
Go
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
|
|
|
package resource
|
|
|
|
import (
|
|
"context"
|
|
_ "decl/tests/mocks"
|
|
_ "fmt"
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestNewServiceResource(t *testing.T) {
|
|
c := NewService()
|
|
assert.NotNil(t, c)
|
|
}
|
|
|
|
func TestUriServiceResource(t *testing.T) {
|
|
c := NewService()
|
|
assert.Nil(t, c.SetURI("service://ssh"))
|
|
assert.Equal(t, "ssh", c.Name)
|
|
}
|
|
|
|
func TestReadServiceResource(t *testing.T) {
|
|
yamlResult := `
|
|
name: "ssh"
|
|
servicemanager: "systemd"
|
|
state: "present"
|
|
`
|
|
c := NewService()
|
|
c.Name = "ssh"
|
|
c.State = "present"
|
|
yamlData, err := c.Read(context.Background())
|
|
assert.Nil(t, err)
|
|
assert.YAMLEq(t, yamlResult, string(yamlData))
|
|
}
|