nginx-proxy-manager-zh/backend/internal/nginx/control_test.go

52 lines
923 B
Go
Raw Normal View History

2023-07-28 01:01:54 -04:00
package nginx
import (
"npm/internal/entity/host"
"npm/internal/model"
"npm/internal/test"
"testing"
"github.com/stretchr/testify/assert"
2023-11-07 18:57:15 -05:00
"go.uber.org/goleak"
2023-07-28 01:01:54 -04:00
)
func TestGetHostFilename(t *testing.T) {
2023-11-07 18:57:15 -05:00
// goleak is used to detect goroutine leaks
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
2023-07-28 01:01:54 -04:00
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)
})
}
}