fix lint errors
Some checks failed
Lint / golangci-lint (push) Failing after 9m49s
Declarative Tests / test (push) Failing after 47s

This commit is contained in:
Matthew Rich 2024-05-05 21:40:34 -07:00
parent 068252570e
commit cf97af96b3
6 changed files with 17 additions and 20 deletions

View File

@ -66,8 +66,7 @@ func (d *Declaration) Resource() Resource {
func (d *Declaration) Apply() error {
stater := d.Attributes.StateMachine()
stater.Trigger(d.Transition)
return nil
return stater.Trigger(d.Transition)
}
func (d *Declaration) SetURI(uri string) error {

View File

@ -218,10 +218,7 @@ resources:
assert.Nil(t, e)
resources := d.Filter(func(d *Declaration) bool {
if d.Type == "file" {
return true
}
return false
return d.Type == "file"
})
assert.Equal(t, 2, len(resources))
}

View File

@ -256,10 +256,7 @@ func (f *ResourceFileInfo) ModTime() time.Time {
}
func (f *ResourceFileInfo) IsDir() bool {
if f.resource.FileType == DirectoryFile {
return true
}
return false
return f.resource.FileType == DirectoryFile
}
func (f *ResourceFileInfo) Sys() any {

View File

@ -32,7 +32,7 @@ func TestNewFileNormalized(t *testing.T) {
absFilePath,_ := filepath.Abs(file)
f := NewNormalizedFile()
assert.NotNil(t, f)
f.SetURI("file://" + file)
assert.Nil(t, f.SetURI("file://" + file))
assert.NotEqual(t, file, f.Path)
assert.Equal(t, absFilePath, f.Path)
@ -290,8 +290,9 @@ func TestFileResourceFileInfo(t *testing.T) {
f.State = "present"
assert.Nil(t, f.Apply())
f.Read(context.Background())
_, readErr := f.Read(context.Background())
assert.Nil(t, readErr)
fi := f.FileInfo()
assert.Equal(t, os.FileMode(0600), fi.Mode().Perm())
}
@ -309,7 +310,8 @@ func TestFileClone(t *testing.T) {
f.State = "present"
assert.Nil(t, f.Apply())
f.Read(ctx)
_, readErr := f.Read(ctx)
assert.Nil(t, readErr)
time.Sleep(100 * time.Millisecond)
@ -319,7 +321,9 @@ func TestFileClone(t *testing.T) {
clone.Path = testCloneFile
assert.Nil(t, clone.Apply())
f.Read(ctx)
_, readErr := f.Read(ctx)
assert.Nil(t, readErr)
clone.Read(ctx)
fmt.Printf("file %#v\nclone %#v\n", f, clone)

View File

@ -228,7 +228,6 @@ func (u *UserType) NewCRUD() (create *Command, read *Command, update *Command, d
}
return NewUserAddCreateCommand(), NewUserReadCommand(), NewUserUpdateCommand(), NewUserDelDeleteCommand()
}
return nil, nil, nil, nil
}
func (u *UserType) UnmarshalValue(value string) error {
@ -271,12 +270,14 @@ func NewUserAddCreateCommand() *Command {
}
c.Extractor = func(out []byte, target any) error {
return nil
/*
for _,line := range strings.Split(string(out), "\n") {
if line == "iptables: Chain already exists." {
return nil
}
}
return fmt.Errorf(string(out))
*/
}
return c
}
@ -295,12 +296,14 @@ func NewAddUserCreateCommand() *Command {
}
c.Extractor = func(out []byte, target any) error {
return nil
/*
for _,line := range strings.Split(string(out), "\n") {
if line == "iptables: Chain already exists." {
return nil
}
}
return fmt.Errorf(string(out))
*/
}
return c
}

View File

@ -73,10 +73,7 @@ func (t *Tar) EmitResources(documents []*resource.Document, filter resource.Reso
for _,document := range documents {
for _,res := range document.Filter(func(d *resource.Declaration) bool {
if d.Type == "file" {
return true
}
return false
return d.Type == "file"
}) {
var f *resource.File = res.Attributes.(*resource.File)
slog.Info("Tar.EmitResources", "file", f)