Skip to content

Commit

Permalink
chec err for csv writer
Browse files Browse the repository at this point in the history
  • Loading branch information
mariiatuzovska committed Dec 11, 2024
1 parent 7d9f8ae commit 0c45a03
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pkg/cmd/cli/run_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ func (s *cmdTestSuite) requireCreateAdvertiserInputFile() string {
}()

w := csv.NewWriter(tmpInputFile)
defer w.Flush()
defer func() {
err := w.Error()
s.Require().NoError(err, "must flush writer")
w.Flush()
}()

for _, email := range s.params.emailsSource {
err = w.Write([]string{email})
Expand All @@ -427,7 +431,11 @@ func (s *cmdTestSuite) requireGenPublisherTwiceEncryptedData() {
}()

twiceEncryptedCsvWriter := csv.NewWriter(twiceEncryptedWriter)
defer twiceEncryptedCsvWriter.Flush()
defer func() {
err := twiceEncryptedCsvWriter.Error()
s.Require().NoError(err, "must flush writer")
twiceEncryptedCsvWriter.Flush()
}()

for _, email := range s.params.emailsSource {
twiceEnc, err := s.params.publisherPairKey.Encrypt([]byte(email))
Expand Down Expand Up @@ -465,7 +473,11 @@ func (s *cmdTestSuite) requireGenAdvertiserTripleEncryptedData() {
s.Require().NoError(err, "must close GCS writer")
}()
tripleEncryptedCsvWriter := csv.NewWriter(tripleEncryptedWriter)
defer tripleEncryptedCsvWriter.Flush()
defer func() {
err := tripleEncryptedCsvWriter.Error()
s.Require().NoError(err, "must flush writer")
tripleEncryptedCsvWriter.Flush()
}()

data, err := twiceEncryptedCsvReader.ReadAll()
s.Require().NoError(err, "must read twice encrypted data")
Expand Down

0 comments on commit 0c45a03

Please sign in to comment.