Skip to content

Commit

Permalink
removing helpers.Contains which now exists in the standard library …
Browse files Browse the repository at this point in the history
…as `slices.Contains`
  • Loading branch information
osamaadam committed May 4, 2024
1 parent 685b360 commit 40f1895
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 58 deletions.
16 changes: 8 additions & 8 deletions cmd/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ package cmd
import (
"os"
"path/filepath"
"slices"
"strings"
"testing"

cf "github.com/osamaadam/cfgrr/configfile"
"github.com/osamaadam/cfgrr/helpers"
"github.com/osamaadam/cfgrr/mapfile"
"github.com/osamaadam/cfgrr/vconfig"
)

var _dummyTestFiles = []string{
".vimrc",
".bashrc",
".zshrc",
".config/nvim/init.vim",
".config/nvim/coc-settings.json",
}
".vimrc",
".bashrc",
".zshrc",
".config/nvim/init.vim",
".config/nvim/coc-settings.json",
}

func TestBackupCmd(t *testing.T) {
backupDir := t.TempDir()
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestBackupCmd(t *testing.T) {

for _, expectedFile := range tt.expectedFiles {
absPath := filepath.Join(backupDir, expectedFile)
if !helpers.Contains(backupFiles, absPath) {
if !slices.Contains(backupFiles, absPath) {
t.Errorf("expected file %s to be backed up, but it wasn't", absPath)
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/findfiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package core
import (
"os"
"path/filepath"
"slices"
"testing"

cf "github.com/osamaadam/cfgrr/configfile"
"github.com/osamaadam/cfgrr/helpers"
"github.com/osamaadam/cfgrr/ignorefile"
)

Expand Down Expand Up @@ -91,7 +91,7 @@ func TestFindFiles(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if !helpers.Contains(tt.expectedFiles, relativePath) {
if !slices.Contains(tt.expectedFiles, relativePath) {
t.Errorf("expected to find %s but didn't", relativePath)
}
}
Expand Down
11 changes: 0 additions & 11 deletions helpers/contains.go

This file was deleted.

36 changes: 0 additions & 36 deletions helpers/contains_test.go

This file was deleted.

3 changes: 2 additions & 1 deletion mapfile/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"os"
"path/filepath"
"slices"

cf "github.com/osamaadam/cfgrr/configfile"
"github.com/osamaadam/cfgrr/helpers"
Expand All @@ -23,7 +24,7 @@ func NewYamlMapFile(path string) *YamlMapFile {
base := filepath.Base(path)
okayExts := []string{".yaml", ".yml"}

if !helpers.Contains(okayExts, ext) {
if !slices.Contains(okayExts, ext) {
path = filepath.Join(filepath.Dir(path), base+".yaml")
}

Expand Down

0 comments on commit 40f1895

Please sign in to comment.