Skip to content

Commit

Permalink
Cleanings
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Jan 10, 2025
1 parent 0b11e66 commit 2355e31
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test_and_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
test:
name: Run Tests and Generate Coverage
runs-on: ubuntu-latest
env:
TB_GITHUB_TESTING: "true"
steps:
# Checkout the repository
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
go.work
go.work.sum
.env
shit
shit*
x
khedra
khedra.log
Expand Down
3 changes: 1 addition & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ every:
@make app

app: $(SRC_GO)
@echo Building khedra...
@mkdir -p $(bin)
@go build -o $(dest) *.go

Expand All @@ -28,7 +27,7 @@ install:
@make build
@mv khedra ~/go/bin

test:
test: $(SRC_GO)
@go test ./...

#-------------------------------------------------
Expand Down
10 changes: 6 additions & 4 deletions pkg/types/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ func SetTestEnv(env []string) func() {
// format "KEY=VALUE". Returns a cleanup function which may be deferred to remove the
// temporary configuration file and unset the environment variables.
func SetupTest(env []string) func() {
originalArgs := os.Args
cleanupFn := SetTestEnv(env)
tempConfigFile := GetConfigFn()
EstablishConfig(tempConfigFile)
return func() {
cleanupFn()
os.Remove(tempConfigFile)
os.Args = originalArgs
}
}

Expand Down Expand Up @@ -122,16 +124,16 @@ func checkValidationErrors(t *testing.T, name string, err error, wantErr bool) {
if err != nil {
if validationErrors, ok := err.(validator.ValidationErrors); ok {
for _, fieldErr := range validationErrors {
t.Errorf("Validation error in test '%s' on field '%s': tag='%s', param='%s', value='%v'",
t.Errorf("Validation error in test '%s' on field '%s': value='%v', param='%s', tag='%s'",
name,
fieldErr.Field(),
fieldErr.Tag(),
fieldErr.Param(),
fieldErr.Value(),
fieldErr.Param(),
fieldErr.Tag(),
)
}
} else {
t.Errorf("Unexpected error in test '%s': %v", name, err)
t.Errorf("Unexpected error in test '%s': expected error = %v, got error = %v", name, wantErr, err != nil)
}
} else {
t.Errorf("Test '%s': expected error = %v, got error = %v", name, wantErr, err != nil)
Expand Down

0 comments on commit 2355e31

Please sign in to comment.