28 lines
843 B
Go
28 lines
843 B
Go
package sysconfdata
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"91porn-server/models/v/sysconfmod"
|
|
)
|
|
|
|
func TestTotalWatchCount(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
config sysconfmod.ConfMap
|
|
want uint64
|
|
}{
|
|
{name: "configured", config: sysconfmod.ConfMap{string(sysconfmod.VCodeTotalWatchCount): "5"}, want: 5},
|
|
{name: "zero is allowed", config: sysconfmod.ConfMap{string(sysconfmod.VCodeTotalWatchCount): "0"}, want: 0},
|
|
{name: "missing", config: sysconfmod.ConfMap{}, want: DefaultTotalWatchCount},
|
|
{name: "invalid", config: sysconfmod.ConfMap{string(sysconfmod.VCodeTotalWatchCount): "invalid"}, want: DefaultTotalWatchCount},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := totalWatchCount(tt.config); got != tt.want {
|
|
t.Fatalf("totalWatchCount() = %d, want %d", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|