Skip to content

Commit

Permalink
fix golangci-lint
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandar Stojanov <[email protected]>
  • Loading branch information
losisin committed Jun 24, 2024
1 parent 782365d commit c00ef81
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bytes"
"io"
"log"
"os"
"testing"

Expand Down Expand Up @@ -47,17 +48,23 @@ func TestMain(t *testing.T) {
args: []string{"schema", "-input", "testdata/basic.yaml"},
setup: func() {
if _, err := os.Stat("schema.yaml"); err == nil {
os.Rename("schema.yaml", "schema.yaml.bak")
if err := os.Rename("schema.yaml", "schema.yaml.bak"); err != nil {
log.Fatalf("Error renaming file: %v", err)
}
}

file, _ := os.Create("schema.yaml")
defer file.Close()
file.WriteString("draft: invalid\n")
if _, err := file.WriteString("draft: invalid\n"); err != nil {
log.Fatalf("Error writing to file: %v", err)
}
},
cleanup: func() {
if _, err := os.Stat("schema.yaml.bak"); err == nil {
os.Remove("schema.yaml")
os.Rename("schema.yaml.bak", "schema.yaml")
if err := os.Rename("schema.yaml.bak", "schema.yaml"); err != nil {
log.Fatalf("Error renaming file: %v", err)
}
} else {
os.Remove("schema.yaml")
}
Expand Down

0 comments on commit c00ef81

Please sign in to comment.