Skip to content

Commit

Permalink
Fix Lint and Gitsign errors
Browse files Browse the repository at this point in the history
Signed-off-by: santoshkal <[email protected]>
  • Loading branch information
santoshkal committed Oct 31, 2023
1 parent 99ffc31 commit e645ae6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ func fetchFileWithCURL(urlStr string) (string, error) {
// Create a cue_downloads directory in /tmp to store the files
dir := filepath.Join(os.TempDir(), "cue_downloads")
if _, err := os.Stat(dir); os.IsNotExist(err) {
os.Mkdir(dir, 0700)
if err := os.Mkdir(dir, 0700); err != nil {
// Handle error here
log.Println("Failed to create directory:", err)
}
} else if err != nil {
// Handle other potential errors from os.Stat
log.Println("Error checking directory:", err)
}

cmd := exec.Command("curl", "-s", "-o", filepath.Join(dir, filename), urlStr)
Expand Down
9 changes: 7 additions & 2 deletions pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
"testing"

log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -139,7 +140,9 @@ func TestReadRegoFile(t *testing.T) {
}

// Create a sample file for testing
os.WriteFile("test.rego", []byte("test content from file"), 0644)
if err := os.WriteFile("test.rego", []byte("test content from file"), 0644); err != nil {
log.Println("Failed to write to file:", err)
}
defer os.Remove("test.rego")

for _, tt := range tests {
Expand Down Expand Up @@ -190,7 +193,9 @@ func TestProcessInputs(t *testing.T) {
}
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/test.cue" {
w.Write([]byte("package test"))
if _, err := w.Write([]byte("package test")); err != nil {
log.Println("Failed to write response:", err)
}
} else {
http.NotFound(w, r)
}
Expand Down

0 comments on commit e645ae6

Please sign in to comment.