Skip to content

Commit

Permalink
Remove temp files (#17)
Browse files Browse the repository at this point in the history
* Remove temp files

* Handle error

* Improve Makefile by adding test-all

* Improve output file names
  • Loading branch information
laenzlinger authored Apr 1, 2024
1 parent 416fa70 commit 43b566d
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
run: make lint

- name: Test
run: make test integration-test
run: make test-all
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ install: ## run the application
test: ## run tests
go test ./...

integration-test: clean docker-build
test-integration: clean docker-build
$(RUN) generate sheet --band-name Band --all
$(RUN) generate sheet --band-name Band "Grand Ole Opry"
$(RUN) generate list --band-name Band "Grand Ole Opry"
$(RUN) generate suisa --band-name Band "Grand Ole Opry"
ls -lart test/Repertoire/out
ls -lartR test/Repertoire/out

test-all: test test-integration

lint: ## lint source code
golangci-lint run
Expand Down
2 changes: 1 addition & 1 deletion cmd/generate_setlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ func generateSetlist(gigName string) error {
return err
}

return convert.HTMLToPDF(filename, filepath.Join(config.Target(), fmt.Sprintf("Setlist %s.pdf", gig.Name)))
return convert.HTMLToPDF(filename, filepath.Join(config.Target(), fmt.Sprintf("Set List %s.pdf", gig.Name)))
}
2 changes: 1 addition & 1 deletion internal/gig/gig.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func New(band config.Band, gig string) (Gig, error) {
return Gig{}, fmt.Errorf("failed to read Gig: %w", err)
}

gigName := fmt.Sprintf("%s@%s", band.Name, gig)
gigName := fmt.Sprintf("%s @ %s", band.Name, gig)
return parse(gigName, content), nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/gig/gig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestNew(t *testing.T) {
name: "good",
args: args{band: config.Band{Name: "MyBand", Source: "Band"}, gig: "Grand Ole Opry"},
want: Gig{
Name: "MyBand@Grand Ole Opry",
Name: "MyBand @ Grand Ole Opry",
Sections: []Section{
{SongTitles: []string{"Frankie and Johnnie", "On the Alamo"}},
{SongTitles: []string{"Nowhere To Go"}},
Expand Down
2 changes: 1 addition & 1 deletion internal/html/pdf/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func HTMLToPDF(in, out string) error {
if err = os.WriteFile(out, buf, 0o600); err != nil {
return fmt.Errorf("failed to write PDF: %w", err)
}
return nil
return os.Remove(in)
}

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/html/template/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Data struct {
}

func CreateSetlist(data *Data) (string, error) {
filename := filepath.Join(config.Target(), fmt.Sprintf("Setlist %s.html", data.Title))
filename := filepath.Join(config.Target(), fmt.Sprintf("Set List %s.html", data.Title))
return createFromTemplate(data, setlistTemplate, filename)
}

Expand Down
5 changes: 3 additions & 2 deletions internal/sheet/sheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func AllForBand(band config.Band) error {
songNames = append(songNames, song)
}
sort.Strings(songNames)
return forSongs(band, songNames, fmt.Sprintf("All %s Songs", band.Name))
return forSongs(band, songNames, fmt.Sprintf("for all %s songs", band.Name))
}

func ForGig(band config.Band, gig gig.Gig) error {
Expand Down Expand Up @@ -77,7 +77,8 @@ func forSongs(band config.Band, songs []string, sheetName string) error {
if err != nil {
return fmt.Errorf("failed to merge PDF files: %w", err)
}
return nil

return os.RemoveAll(config.PlaceholderDir())
}

func (s *Sheet) verifySheetPdf() error {
Expand Down

0 comments on commit 43b566d

Please sign in to comment.