45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package coinglass
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestResolveSeed_AllBranches(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
v string
|
|
path string
|
|
reqCacheTsV2 string
|
|
respTime string
|
|
wantSeed string
|
|
}{
|
|
{"v=0 → cache-ts-v2", "0", "/api/x", "1735689600000", "1735689601000", "1735689600000"},
|
|
{"v=1 → path", "1", "/api/index/v2/liqHeatMap", "ts", "rt", "/api/index/v2/liqHeatMap"},
|
|
{"v=2 → resp time", "2", "/api/x", "ts", "1735689601000", "1735689601000"},
|
|
{"v=55 → bundle const", "55", "", "", "", "170b070da9654622"},
|
|
{"v=66 → bundle const", "66", "", "", "", "d6537d845a964081"},
|
|
{"v=77 → bundle const", "77", "", "", "", "863f08689c97435b"},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
got, err := resolveSeed(tc.v, tc.path, tc.reqCacheTsV2, tc.respTime)
|
|
require.NoError(t, err)
|
|
require.Equal(t, tc.wantSeed, got)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestResolveSeed_UnknownV(t *testing.T) {
|
|
cases := []string{"3", "88", "99", "v0", ""}
|
|
for _, v := range cases {
|
|
t.Run("unknown_v="+v, func(t *testing.T) {
|
|
_, err := resolveSeed(v, "/p", "ts", "rt")
|
|
require.Error(t, err)
|
|
require.True(t, errors.Is(err, ErrUnknownV), "want ErrUnknownV, got %v", err)
|
|
})
|
|
}
|
|
}
|