Skip to content

Commit

Permalink
feat: create summary for cloc
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Sep 16, 2020
1 parent 6a309cd commit 3450099
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/domain/cloc/cloc_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ type LanguageReportEnd struct {

type ClocSummary struct {
Header HeaderStruct
Sum SummaryStruct `yaml:"SUM"`
}
43 changes: 40 additions & 3 deletions pkg/domain/cloc/cloc_summary_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cloc


import (
"fmt"
. "github.com/onsi/gomega"
"gopkg.in/yaml.v2"
"log"
Expand Down Expand Up @@ -33,4 +31,43 @@ header:
}

g.Expect(header.Header.Version).To(Equal("2.13.0"))
}
}

func Test_Cloc_Yaml_File_Parse_Model(t *testing.T) {
t.Parallel()
g := NewGomegaWithT(t)


var data = `
# https://github.com/boyter/scc/
header:
url: https://github.com/boyter/scc/
version: 2.13.0
elapsed_seconds: 0.006
n_files: 25
n_lines: 4045
files_per_second: 4166.666666666667
lines_per_second: 674166.6666666666
Java:
name: Java
code: 3010
comment: 516
blank: 519
nFiles: 25
SUM:
code: 3010
comment: 516
blank: 519
nFiles: 25
`

var header = ClocSummary{}
err := yaml.Unmarshal([]byte(data), &header)
if err != nil {
log.Fatalf("error: %v", header)
}

g.Expect(header.Header.Version).To(Equal("2.13.0"))
g.Expect(header.Sum.Code).To(Equal(int64(3010)))
}

0 comments on commit 3450099

Please sign in to comment.