Skip to content

Commit

Permalink
test: added code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-cardenas-coding committed Nov 18, 2023
1 parent 7f1ecb6 commit 241f198
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ jobs:
with:
args: -v


- name: Execute Go tests
run: go test -v ./...
run: make tests-coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Test CLI
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ terraform.tfvars
lambda.zip
main
.DS_STORE
main
main
coverage.out
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ build: ## Build the binary file

tests: ## Run tests
@echo "Running tests"
go test -race -shuffle on ./...
go test -race -shuffle on ./...


tests-coverage: ## Start Go Test with code coverage
@echo "Running Go Tests with code coverage"
go test -race -shuffle on -cover -coverprofile=coverage.out ./...

view-coverage: ## View the code coverage
@echo "Viewing the code coverage"
go tool cover -html=coverage.out
3 changes: 2 additions & 1 deletion cmd/clean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func TestCalculateFileSize(t *testing.T) {
}

func TestDisplayDuration(t *testing.T) {
startTime := time.Now().Add(-time.Minute * 2)
startTime := time.Now().Add(time.Minute * 2)
var buf bytes.Buffer
log.SetOutput(&buf)

Expand All @@ -366,4 +366,5 @@ func TestDisplayDuration(t *testing.T) {
if match, _ := regexp.MatchString(want, got); !match {
t.Errorf("displayDuration() = %q, want %q", got, want)
}
buf.Reset()
}

0 comments on commit 241f198

Please sign in to comment.