github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/tools/blocksconvert/plan_file_test.go (about) 1 package blocksconvert 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/stretchr/testify/require" 8 ) 9 10 func TestIsProgressFile(t *testing.T) { 11 for _, tc := range []struct { 12 input string 13 exp bool 14 base string 15 t time.Time 16 }{ 17 {input: "hello/world.progress.123456", exp: true, base: "hello/world", t: time.Unix(123456, 0)}, 18 {input: "hello/world.progress.123456123456123456123456123456123456", exp: false, base: "", t: time.Time{}}, 19 {input: "hello/world.notprogress.123456", exp: false, base: "", t: time.Time{}}, 20 {input: "hello/world.plan", exp: false, base: "", t: time.Time{}}, 21 } { 22 ok, base, tm := IsProgressFilename(tc.input) 23 require.Equal(t, tc.exp, ok, tc.input) 24 require.Equal(t, tc.base, base, tc.input) 25 require.Equal(t, tc.t, tm, tc.input) 26 } 27 }