mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
58 lines
956 B
Go
58 lines
956 B
Go
package database
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDataSourceName(t *testing.T) {
|
|
type args struct {
|
|
configPath string
|
|
name string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want string
|
|
}{
|
|
{
|
|
name: "default",
|
|
args: args{
|
|
configPath: "",
|
|
name: "autobrr.db",
|
|
},
|
|
want: "autobrr.db",
|
|
},
|
|
{
|
|
name: "path_1",
|
|
args: args{
|
|
configPath: "/config",
|
|
name: "autobrr.db",
|
|
},
|
|
want: "/config/autobrr.db",
|
|
},
|
|
{
|
|
name: "path_2",
|
|
args: args{
|
|
configPath: "/config/",
|
|
name: "autobrr.db",
|
|
},
|
|
want: "/config/autobrr.db",
|
|
},
|
|
{
|
|
name: "path_3",
|
|
args: args{
|
|
configPath: "/config//",
|
|
name: "autobrr.db",
|
|
},
|
|
want: "/config/autobrr.db",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := DataSourceName(tt.args.configPath, tt.args.name)
|
|
assert.Equal(t, tt.want, got)
|
|
})
|
|
}
|
|
}
|