Skip to content

Commit

Permalink
test: Fix array deep equal test order
Browse files Browse the repository at this point in the history
  • Loading branch information
reobin committed Jun 21, 2024
1 parent 9e92c3b commit f761b89
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions internal/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package repository

import (
"reflect"
"sort"
"testing"
"time"

Expand Down Expand Up @@ -538,50 +539,41 @@ func TestSynchronizeVimColorSchemes(t *testing.T) {
Valid: true,
FileURL: "old.url",
Data: VimColorSchemeData{
Dark: []VimColorSchemeGroup{
{HexCode: "#000000", Name: "NormalBg"},
},
Dark: []VimColorSchemeGroup{{HexCode: "#000000", Name: "NormalBg"}},
Light: nil,
},
},
}

newList := []VimColorScheme{
{
Name: "test",
FileURL: "new.url",
},
{
Name: "new",
FileURL: "new.url",
},
{Name: "test", FileURL: "new.url"},
{Name: "new", FileURL: "new.url"},
}

expectedList := []VimColorScheme{
{Name: "new", FileURL: "new.url"},
{
Name: "test",
Valid: true,
FileURL: "new.url",
Data: VimColorSchemeData{
Dark: []VimColorSchemeGroup{
{HexCode: "#000000", Name: "NormalBg"},
},
Dark: []VimColorSchemeGroup{{HexCode: "#000000", Name: "NormalBg"}},
Light: nil,
},
},
{
Name: "new",
FileURL: "new.url",
},
}

repository := Repository{VimColorSchemes: originalList}

repository.SyncVimColorSchemes(newList)

sort.Slice(repository.VimColorSchemes, func(i, j int) bool {
return repository.VimColorSchemes[i].Name < repository.VimColorSchemes[j].Name
})

if !reflect.DeepEqual(repository.VimColorSchemes, expectedList) {
t.Errorf(
"Incorrect result for SyncVimColorSchemes, got: %v, want length: %v",
"Incorrect result for SyncVimColorSchemes, got: %v, want: %v",
repository.VimColorSchemes,
expectedList,
)
Expand Down

0 comments on commit f761b89

Please sign in to comment.