package util import ( "os" "testing" ) func TestPrintQuotedCsv(t *testing.T) { data := [][]string{ {"header1", "header2", "header3"}, {"test1", "test2", "test3"}, {"test1", "test2", "test3"}, } f, err := os.CreateTemp("", "testcsv") if err != nil { t.Errorf(err.Error()) } filename := f.Name() f.Close() defer os.Remove(f.Name()) want := `"header1";"header2";"header3" "test1";"test2";"test3" "test1";"test2";"test3" ` if err := PrintQuotedCsv(data, filename, ";"); err != nil { t.Errorf(err.Error()) } have, err := os.ReadFile(filename) if err != nil { t.Errorf(err.Error()) } if want != string(have) { t.Errorf("got \n%v\n wanted\n%v\n", string(have), want) } }