Skip to content

Commit

Permalink
Flush the block coverages from the report to handle `Error 413 (Reque…
Browse files Browse the repository at this point in the history
…st Entity Too Large)!!1` error.
  • Loading branch information
k1LoW committed Sep 15, 2021
1 parent 176d170 commit 3e59a20
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ var rootCmd = &cobra.Command{
if err := c.BuildReportConfig(); err != nil {
return err
}
r.Coverage.FlushBlockCoverages()
datastores := []datastore.Datastore{}
for _, s := range c.Report.Datastores {
d, err := datastore.New(ctx, s, c.Root())
Expand Down
8 changes: 7 additions & 1 deletion pkg/coverage/coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type FileCoverage struct {
File string `json:"file"`
Total int `json:"total"`
Covered int `json:"covered"`
Blocks BlockCoverages `json:"blocks"`
Blocks BlockCoverages `json:"blocks,omitempty"`
cache map[int]BlockCoverages
}

Expand Down Expand Up @@ -63,6 +63,12 @@ func NewFileCoverage(file string) *FileCoverage {
}
}

func (c *Coverage) FlushBlockCoverages() {
for _, f := range c.Files {
f.Blocks = BlockCoverages{}
}
}

func (coverages FileCoverages) FindByFile(file string) (*FileCoverage, error) {
for _, c := range coverages {
if c.File == file {
Expand Down
3 changes: 3 additions & 0 deletions report/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func TestTable(t *testing.T) {
if got := r.Table(); got != tt.want {
t.Errorf("got\n%v\nwant\n%v", got, tt.want)
}
_ = r.String()
r.Coverage.FlushBlockCoverages()
_ = r.String()
}
}

Expand Down

0 comments on commit 3e59a20

Please sign in to comment.