Skip to content

Commit 3df5ec8

Browse files
committed
fix tests, rename
1 parent 6e40636 commit 3df5ec8

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

internal/nix/nixprofile/item.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type NixProfileListItem struct {
2525
lockedReference string
2626

2727
// The store path(s) of the package.
28-
nixStorePath []string
28+
nixStorePaths []string
2929
}
3030

3131
// AttributePath parses the package attribute from the NixProfileListItem.lockedReference
@@ -62,6 +62,6 @@ func (item *NixProfileListItem) String() string {
6262
item.index,
6363
item.unlockedReference,
6464
item.lockedReference,
65-
item.nixStorePath,
65+
item.nixStorePaths,
6666
)
6767
}

internal/nix/nixprofile/profile.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func ProfileListItems(
5858
index: index,
5959
unlockedReference: element.OriginalURL + "#" + element.AttrPath,
6060
lockedReference: element.URL + "#" + element.AttrPath,
61-
nixStorePath: element.StorePaths,
61+
nixStorePaths: element.StorePaths,
6262
})
6363
}
6464
return items, nil
@@ -133,8 +133,8 @@ func ProfileListIndex(args *ProfileListIndexArgs) (int, error) {
133133
return -1, errors.Wrapf(err, "failed to get installable for %s", args.DevPkg.String())
134134
}
135135
for _, item := range items {
136-
if len(item.nixStorePath) == 1 && // this should always be true
137-
pathInStore == item.nixStorePath[0] {
136+
if len(item.nixStorePaths) == 1 && // this should always be true
137+
pathInStore == item.nixStorePaths[0] {
138138
return item.index, nil
139139
}
140140
}
@@ -192,15 +192,15 @@ func parseNixProfileListItem(line string) (*NixProfileListItem, error) {
192192
lockedReference := scanner.Text()
193193

194194
if !scanner.Scan() {
195-
return nil, redact.Errorf("error parsing \"nix profile list\" output: line is missing nixStorePath: %s", line)
195+
return nil, redact.Errorf("error parsing \"nix profile list\" output: line is missing nixStorePaths: %s", line)
196196
}
197197
nixStorePath := scanner.Text()
198198

199199
return &NixProfileListItem{
200200
index: index,
201201
unlockedReference: unlockedReference,
202202
lockedReference: lockedReference,
203-
nixStorePath: []string{nixStorePath},
203+
nixStorePaths: []string{nixStorePath},
204204
}, nil
205205
}
206206

internal/nix/nixprofile/profile_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package nixprofile
55

66
import (
77
"fmt"
8+
"reflect"
89
"testing"
910
)
1011

@@ -32,7 +33,7 @@ func TestNixProfileListItem(t *testing.T) {
3233
index: 0,
3334
unlockedReference: "flake:NixOS/nixpkgs/52e3e80afff4b16ccb7c52e9f0f5220552f03d04#legacyPackages.x86_64-darwin.go_1_19",
3435
lockedReference: "github:NixOS/nixpkgs/52e3e80afff4b16ccb7c52e9f0f5220552f03d04#legacyPackages.x86_64-darwin.go_1_19",
35-
nixStorePath: "/nix/store/w0lyimyyxxfl3gw40n46rpn1yjrl3q85-go-1.19.3",
36+
nixStorePaths: []string{"/nix/store/w0lyimyyxxfl3gw40n46rpn1yjrl3q85-go-1.19.3"},
3637
},
3738
attrPath: "legacyPackages.x86_64-darwin.go_1_19",
3839
packageName: "go_1_19",
@@ -51,7 +52,7 @@ func TestNixProfileListItem(t *testing.T) {
5152
2,
5253
"github:NixOS/nixpkgs/52e3e80afff4b16ccb7c52e9f0f5220552f03d04#legacyPackages.x86_64-darwin.python39Packages.numpy",
5354
"github:NixOS/nixpkgs/52e3e80afff4b16ccb7c52e9f0f5220552f03d04#legacyPackages.x86_64-darwin.python39Packages.numpy",
54-
"/nix/store/qly36iy1p4q1h5p4rcbvsn3ll0zsd9pd-python3.9-numpy-1.23.3",
55+
[]string{"/nix/store/qly36iy1p4q1h5p4rcbvsn3ll0zsd9pd-python3.9-numpy-1.23.3"},
5556
},
5657
attrPath: "legacyPackages.x86_64-darwin.python39Packages.numpy",
5758
packageName: "python39Packages.numpy",
@@ -75,7 +76,7 @@ func testItem(t *testing.T, line string, expected expectedTestData) {
7576
t.Fatalf("expected NixProfileListItem to be non-nil")
7677
}
7778

78-
if *item != *expected.item {
79+
if !reflect.DeepEqual(item, expected.item) {
7980
t.Fatalf("expected parsed NixProfileListItem to be %s but got %s",
8081
expected.item,
8182
item,

0 commit comments

Comments
 (0)