jx/internal/resource/service_test.go
Matthew Rich 1460d2285b
Some checks failed
Declarative Tests / build-ubuntu-focal (push) Waiting to run
Lint / golangci-lint (push) Failing after 15s
Declarative Tests / test (push) Failing after 5s
Declarative Tests / build-fedora (push) Has been cancelled
add support for configuration documents
2024-07-01 14:54:18 -07:00

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))
}