From e8dee1de8ee35db5c8a462e8fc38c7a4303b7254 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 6 May 2024 21:04:48 +0200 Subject: [PATCH] use assert instead of require --- git/clone_test.go | 10 +++++----- git/commit_test.go | 14 +++++++------- git/config_test.go | 18 +++++++++--------- git/init_test.go | 6 +++--- git/remote_test.go | 14 +++++++------- git/status_test.go | 12 ++++++------ plugin/rsync_test.go | 6 +++--- plugin/util_test.go | 20 ++++++++++---------- 8 files changed, 50 insertions(+), 50 deletions(-) diff --git a/git/clone_test.go b/git/clone_test.go index 6e93165..54a34d5 100644 --- a/git/clone_test.go +++ b/git/clone_test.go @@ -3,7 +3,7 @@ package git import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" ) func TestFetchSource(t *testing.T) { @@ -33,8 +33,8 @@ func TestFetchSource(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.FetchSource() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } @@ -66,8 +66,8 @@ func TestCheckoutHead(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.CheckoutHead() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } diff --git a/git/commit_test.go b/git/commit_test.go index f8a4c14..7e64d71 100644 --- a/git/commit_test.go +++ b/git/commit_test.go @@ -3,7 +3,7 @@ package git import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" ) func TestAdd(t *testing.T) { @@ -24,8 +24,8 @@ func TestAdd(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.Add() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } @@ -55,8 +55,8 @@ func TestIsCleanTree(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.IsCleanTree() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } @@ -98,8 +98,8 @@ func TestCommit(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.Commit() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } diff --git a/git/config_test.go b/git/config_test.go index e7d6f62..c47a5cf 100644 --- a/git/config_test.go +++ b/git/config_test.go @@ -3,7 +3,7 @@ package git import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" ) func TestConfigAutocorrect(t *testing.T) { @@ -33,8 +33,8 @@ func TestConfigAutocorrect(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.ConfigAutocorrect() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } @@ -60,8 +60,8 @@ func TestConfigUserEmail(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.ConfigUserEmail() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } @@ -87,8 +87,8 @@ func TestConfigUserName(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.ConfigUserName() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } @@ -117,8 +117,8 @@ func TestConfigSSLVerify(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.ConfigSSLVerify(tt.skipVerify) - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } diff --git a/git/init_test.go b/git/init_test.go index bd3787a..80f466d 100644 --- a/git/init_test.go +++ b/git/init_test.go @@ -3,7 +3,7 @@ package git import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" ) func TestInit(t *testing.T) { @@ -25,8 +25,8 @@ func TestInit(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.Init() - require.Equal(t, tt.expected, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.expected, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } diff --git a/git/remote_test.go b/git/remote_test.go index 859f513..df7d3da 100644 --- a/git/remote_test.go +++ b/git/remote_test.go @@ -3,7 +3,7 @@ package git import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" ) func TestRemoteRemove(t *testing.T) { @@ -40,8 +40,8 @@ func TestRemoteRemove(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.RemoteRemove() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } @@ -74,8 +74,8 @@ func TestRemoteAdd(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.RemoteAdd() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } @@ -132,8 +132,8 @@ func TestRemotePush(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.RemotePush() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } diff --git a/git/status_test.go b/git/status_test.go index b5752bb..aa539e3 100644 --- a/git/status_test.go +++ b/git/status_test.go @@ -5,7 +5,7 @@ import ( "path/filepath" "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" ) func TestStatus(t *testing.T) { @@ -38,8 +38,8 @@ func TestStatus(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := tt.repo.Status() - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) }) } } @@ -71,16 +71,16 @@ func TestIsDirty(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if err := tt.repo.Init().Run(); err != nil { - require.NoError(t, err) + assert.NoError(t, err) } if tt.want { _, err := os.Create(filepath.Join(tt.repo.WorkDir, "dummy")) - require.NoError(t, err) + assert.NoError(t, err) } isDirty := tt.repo.IsDirty() - require.Equal(t, tt.want, isDirty) + assert.Equal(t, tt.want, isDirty) }) } } diff --git a/plugin/rsync_test.go b/plugin/rsync_test.go index a6a2ebb..04563c3 100644 --- a/plugin/rsync_test.go +++ b/plugin/rsync_test.go @@ -3,7 +3,7 @@ package plugin import ( "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" ) func TestSyncDirectories(t *testing.T) { @@ -39,8 +39,8 @@ func TestSyncDirectories(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd := SyncDirectories(tt.exclude, tt.del, tt.src, tt.dest) - require.Equal(t, tt.want, cmd.Cmd.Args) - require.Equal(t, tt.src, cmd.Cmd.Dir) + assert.Equal(t, tt.want, cmd.Cmd.Args) + assert.Equal(t, tt.src, cmd.Cmd.Dir) }) } } diff --git a/plugin/util_test.go b/plugin/util_test.go index 9d35e5d..bfa510a 100644 --- a/plugin/util_test.go +++ b/plugin/util_test.go @@ -6,7 +6,7 @@ import ( "path/filepath" "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" ) func TestWriteSSHKey(t *testing.T) { @@ -34,20 +34,20 @@ func TestWriteSSHKey(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := WriteSSHKey(tt.dir, tt.privateKey) if tt.wantErr { - require.Error(t, err) + assert.Error(t, err) return } - require.NoError(t, err) + assert.NoError(t, err) privateKeyPath := filepath.Join(tt.dir, ".ssh", "id_rsa") _, err = os.Stat(privateKeyPath) - require.NoError(t, err) + assert.NoError(t, err) configPath := filepath.Join(tt.dir, ".ssh", "config") _, err = os.Stat(configPath) - require.NoError(t, err) + assert.NoError(t, err) }) } } @@ -75,22 +75,22 @@ func TestWriteNetrc(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := WriteNetrc(tt.path, tt.machine, tt.login, tt.password) if tt.wantErr { - require.Error(t, err) + assert.Error(t, err) return } - require.NoError(t, err) + assert.NoError(t, err) netrcPath := filepath.Join(tt.path, ".netrc") _, err = os.Stat(netrcPath) - require.NoError(t, err) + assert.NoError(t, err) content, err := os.ReadFile(netrcPath) - require.NoError(t, err) + assert.NoError(t, err) expected := fmt.Sprintf("machine %s\nlogin %s\npassword %s\n", tt.machine, tt.login, tt.password) - require.Equal(t, expected, string(content)) + assert.Equal(t, expected, string(content)) }) } }