Add more unit tests

This commit is contained in:
Jamie Curnow
2023-07-28 15:01:54 +10:00
parent 7f9a1f5a98
commit e5ade3b4ea
11 changed files with 162 additions and 83 deletions

View File

@ -0,0 +1,47 @@
package nginx
import (
"npm/internal/entity/host"
"npm/internal/model"
"npm/internal/test"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetHostFilename(t *testing.T) {
test.InitConfig(t)
tests := []struct {
name string
host host.Model
append string
want string
}{
{
"test1",
host.Model{
ModelBase: model.ModelBase{
ID: 10,
},
},
"",
"/data/nginx/hosts/host_10.conf",
},
{
"test2",
host.Model{
ModelBase: model.ModelBase{
ID: 10,
},
},
".deleted",
"/data/nginx/hosts/host_10.conf.deleted",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
filename := getHostFilename(tt.host, tt.append)
assert.Equal(t, tt.want, filename)
})
}
}