Skip to content

Commit

Permalink
chore: transitional commit
Browse files Browse the repository at this point in the history
I want to default to private rather than public. In order to do that,
I need tests to be in the package itself.
  • Loading branch information
telemachus committed Oct 16, 2024
1 parent a8f1e68 commit 6024978
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions cli/unmarshal_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package cli_test
package cli

import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/telemachus/gitmirror/cli"
)

const (
exitFailure = 1
exitSuccess = 0
)

func makeRepos() []*cli.Repo {
return []*cli.Repo{
func makeRepos() []*Repo {
return []*Repo{
{Remote: "backup", Dir: "/home/username/foo"},
{Remote: "backblaze", Dir: "/Users/foo/bar"},
{Remote: "backup", Dir: "/home/username/bar"},
Expand All @@ -24,17 +18,17 @@ func makeRepos() []*cli.Repo {

// TODO: Write a test method for toml files with $HOME replaced by the user’s
// home directory.
// func makeBackupsForReplacement() []*cli.Repo {
// backups := make([]*cli.Repo, 0, 2)
// backups = append(backups, &cli.Repo{Remote: "backup"})
// backups = append(backups, &cli.Repo{Remote: "backblaze", Dir: ""})
// func makeBackupsForReplacement() []*Repo {
// backups := make([]*Repo, 0, 2)
// backups = append(backups, &Repo{Remote: "backup"})
// backups = append(backups, &Repo{Remote: "backblaze", Dir: ""})
// return backups
// }

func TestUnmarshalSuccess(t *testing.T) {
t.Parallel()
expected := makeRepos()
app := &cli.App{}
app := &App{}
actual := app.Unmarshal("testdata/backups.toml", false)
if app.ExitValue != exitSuccess {
t.Fatal("app.ExitValue != exitSuccess")
Expand All @@ -46,7 +40,7 @@ func TestUnmarshalSuccess(t *testing.T) {

func TestUnmarshalFailure(t *testing.T) {
t.Parallel()
app := &cli.App{}
app := &App{}
app.Unmarshal("testdata/nope.toml", false)
if app.ExitValue != exitFailure {
t.Errorf("expected exit status: %d; actual exit status: %d", exitFailure, app.ExitValue)
Expand All @@ -56,7 +50,7 @@ func TestUnmarshalFailure(t *testing.T) {
func TestUnmarshalReplace(t *testing.T) {
t.Parallel()
expected := makeRepos()
app := &cli.App{}
app := &App{}
actual := app.Unmarshal("testdata/backups.toml", false)
if app.ExitValue != exitSuccess {
t.Fatal("app.ExitValue != exitSuccess")
Expand Down

0 comments on commit 6024978

Please sign in to comment.