0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-11-24 22:50:39 +00:00

use assert instead of require

This commit is contained in:
Robert Kaussow 2024-05-06 21:04:48 +02:00
parent 198aab7784
commit e8dee1de8e
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
8 changed files with 50 additions and 50 deletions

View File

@ -3,7 +3,7 @@ package git
import ( import (
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/assert"
) )
func TestFetchSource(t *testing.T) { func TestFetchSource(t *testing.T) {
@ -33,8 +33,8 @@ func TestFetchSource(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.FetchSource() cmd := tt.repo.FetchSource()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }
@ -66,8 +66,8 @@ func TestCheckoutHead(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.CheckoutHead() cmd := tt.repo.CheckoutHead()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }

View File

@ -3,7 +3,7 @@ package git
import ( import (
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/assert"
) )
func TestAdd(t *testing.T) { func TestAdd(t *testing.T) {
@ -24,8 +24,8 @@ func TestAdd(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.Add() cmd := tt.repo.Add()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }
@ -55,8 +55,8 @@ func TestIsCleanTree(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.IsCleanTree() cmd := tt.repo.IsCleanTree()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }
@ -98,8 +98,8 @@ func TestCommit(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.Commit() cmd := tt.repo.Commit()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }

View File

@ -3,7 +3,7 @@ package git
import ( import (
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/assert"
) )
func TestConfigAutocorrect(t *testing.T) { func TestConfigAutocorrect(t *testing.T) {
@ -33,8 +33,8 @@ func TestConfigAutocorrect(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.ConfigAutocorrect() cmd := tt.repo.ConfigAutocorrect()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }
@ -60,8 +60,8 @@ func TestConfigUserEmail(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.ConfigUserEmail() cmd := tt.repo.ConfigUserEmail()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }
@ -87,8 +87,8 @@ func TestConfigUserName(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.ConfigUserName() cmd := tt.repo.ConfigUserName()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }
@ -117,8 +117,8 @@ func TestConfigSSLVerify(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.ConfigSSLVerify(tt.skipVerify) cmd := tt.repo.ConfigSSLVerify(tt.skipVerify)
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }

View File

@ -3,7 +3,7 @@ package git
import ( import (
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/assert"
) )
func TestInit(t *testing.T) { func TestInit(t *testing.T) {
@ -25,8 +25,8 @@ func TestInit(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.Init() cmd := tt.repo.Init()
require.Equal(t, tt.expected, cmd.Cmd.Args) assert.Equal(t, tt.expected, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }

View File

@ -3,7 +3,7 @@ package git
import ( import (
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/assert"
) )
func TestRemoteRemove(t *testing.T) { func TestRemoteRemove(t *testing.T) {
@ -40,8 +40,8 @@ func TestRemoteRemove(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.RemoteRemove() cmd := tt.repo.RemoteRemove()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }
@ -74,8 +74,8 @@ func TestRemoteAdd(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.RemoteAdd() cmd := tt.repo.RemoteAdd()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }
@ -132,8 +132,8 @@ func TestRemotePush(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.RemotePush() cmd := tt.repo.RemotePush()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }

View File

@ -5,7 +5,7 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/assert"
) )
func TestStatus(t *testing.T) { func TestStatus(t *testing.T) {
@ -38,8 +38,8 @@ func TestStatus(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := tt.repo.Status() cmd := tt.repo.Status()
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir) assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
}) })
} }
} }
@ -71,16 +71,16 @@ func TestIsDirty(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
if err := tt.repo.Init().Run(); err != nil { if err := tt.repo.Init().Run(); err != nil {
require.NoError(t, err) assert.NoError(t, err)
} }
if tt.want { if tt.want {
_, err := os.Create(filepath.Join(tt.repo.WorkDir, "dummy")) _, err := os.Create(filepath.Join(tt.repo.WorkDir, "dummy"))
require.NoError(t, err) assert.NoError(t, err)
} }
isDirty := tt.repo.IsDirty() isDirty := tt.repo.IsDirty()
require.Equal(t, tt.want, isDirty) assert.Equal(t, tt.want, isDirty)
}) })
} }
} }

View File

@ -3,7 +3,7 @@ package plugin
import ( import (
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/assert"
) )
func TestSyncDirectories(t *testing.T) { func TestSyncDirectories(t *testing.T) {
@ -39,8 +39,8 @@ func TestSyncDirectories(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := SyncDirectories(tt.exclude, tt.del, tt.src, tt.dest) cmd := SyncDirectories(tt.exclude, tt.del, tt.src, tt.dest)
require.Equal(t, tt.want, cmd.Cmd.Args) assert.Equal(t, tt.want, cmd.Cmd.Args)
require.Equal(t, tt.src, cmd.Cmd.Dir) assert.Equal(t, tt.src, cmd.Cmd.Dir)
}) })
} }
} }

View File

@ -6,7 +6,7 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/assert"
) )
func TestWriteSSHKey(t *testing.T) { func TestWriteSSHKey(t *testing.T) {
@ -34,20 +34,20 @@ func TestWriteSSHKey(t *testing.T) {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
err := WriteSSHKey(tt.dir, tt.privateKey) err := WriteSSHKey(tt.dir, tt.privateKey)
if tt.wantErr { if tt.wantErr {
require.Error(t, err) assert.Error(t, err)
return return
} }
require.NoError(t, err) assert.NoError(t, err)
privateKeyPath := filepath.Join(tt.dir, ".ssh", "id_rsa") privateKeyPath := filepath.Join(tt.dir, ".ssh", "id_rsa")
_, err = os.Stat(privateKeyPath) _, err = os.Stat(privateKeyPath)
require.NoError(t, err) assert.NoError(t, err)
configPath := filepath.Join(tt.dir, ".ssh", "config") configPath := filepath.Join(tt.dir, ".ssh", "config")
_, err = os.Stat(configPath) _, 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) { t.Run(tt.name, func(t *testing.T) {
err := WriteNetrc(tt.path, tt.machine, tt.login, tt.password) err := WriteNetrc(tt.path, tt.machine, tt.login, tt.password)
if tt.wantErr { if tt.wantErr {
require.Error(t, err) assert.Error(t, err)
return return
} }
require.NoError(t, err) assert.NoError(t, err)
netrcPath := filepath.Join(tt.path, ".netrc") netrcPath := filepath.Join(tt.path, ".netrc")
_, err = os.Stat(netrcPath) _, err = os.Stat(netrcPath)
require.NoError(t, err) assert.NoError(t, err)
content, err := os.ReadFile(netrcPath) 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) 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))
}) })
} }
} }