package export import ( "github.com/stretchr/testify/assert" "os" "testing" ) func TestCSVExporter_Export(t *testing.T) { data := NewMysqlDataFetcher("aaa") pwd, _ := os.Getwd() file := NewCSV(pwd+"/aa-{begin}.csv", 5, map[string]string{"begin": "202301"}) e := NewCVSExporter(data, file) file.Open() err := e.Export("aa", "字段1") file.Close() assert.Nil(t, err) assert.FileExists(t, pwd+"/aa-202301_0.csv") assert.FileExists(t, pwd+"/aa-202301_1.csv") assert.NoFileExists(t, pwd+"/aa-202301_2.csv") _ = os.Remove(pwd + "/aa-202301_0.csv") _ = os.Remove(pwd + "/aa-202301_1.csv") }