Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sayden committed Oct 25, 2024
1 parent 60ce892 commit 6b48bea
Show file tree
Hide file tree
Showing 16 changed files with 215 additions and 311 deletions.
4 changes: 4 additions & 0 deletions counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func (c *Counter) GetCounterFilename(position int, suffix string, filenumber int
res += fmt.Sprintf(" %03d", filenumber)
}
}
if res == "" {
res = fmt.Sprintf("%03d", filenumber)
}
res = strings.TrimSpace(res)

filenamesInUse[res] = true

Expand Down
6 changes: 4 additions & 2 deletions counter_prototype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ func TestJSONPrototypes(t *testing.T) {
// check the marshalling of the template to an expected byte slice
actualBytes, err := json.MarshalIndent(newTempl, "", " ")
assert.NoError(t, err)
assert.Equal(t, 12621, len(actualBytes))
if !assert.Equal(t, 13360, len(actualBytes)) {
t.FailNow()
}

expectedFile, err := os.Open("./testdata/parse_template_01.json")
assert.NoError(t, err)
Expand All @@ -69,7 +71,7 @@ func TestJSONPrototypes(t *testing.T) {
assert.NoError(t, err)

// // ensure we are using the expected file and that it has not been altered by mistake
if !assert.Equal(t, 12621, len(expectedBytes), "expected file has been altered, aborting test") {
if !assert.Equal(t, 13360, len(expectedBytes), "expected file has been altered, aborting test") {
t.FailNow()
}

Expand Down
2 changes: 1 addition & 1 deletion counter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestGetCounterFilename(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
got := tt.counter.GetCounterFilename(tt.position, tt.suffix, tt.filenumber, tt.filenamesInUse)
if got != tt.expected {
t.Errorf("GetCounterFilename() = %v, want %v", got, tt.expected)
t.Errorf("GetCounterFilename() = '%v', want '%v'", got, tt.expected)
}
})
}
Expand Down
5 changes: 2 additions & 3 deletions fsops/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"encoding/xml"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand All @@ -16,7 +15,7 @@ import (
func ReadMarkupFile(markupFilepath string, destination interface{}) error {
extension := filepath.Ext(markupFilepath)

data, err := ioutil.ReadFile(markupFilepath)
data, err := os.ReadFile(markupFilepath)
if err != nil {
return errors.Wrap(err, "could not read file content")
}
Expand All @@ -38,7 +37,7 @@ func ReadMarkupFile(markupFilepath string, destination interface{}) error {
}

func FilenameExistsInFolder(filename, folder string) bool {
fs, err := ioutil.ReadDir(folder)
fs, err := os.ReadDir(folder)
if err != nil {
log.WithError(err).Fatal("could not read images folder")
}
Expand Down
106 changes: 0 additions & 106 deletions output/area_processor.go

This file was deleted.

138 changes: 0 additions & 138 deletions output/card_processor.go

This file was deleted.

Loading

0 comments on commit 6b48bea

Please sign in to comment.