|
| 1 | +//nolint:dupl |
1 | 2 | package nix
|
2 | 3 |
|
3 | 4 | import (
|
@@ -118,17 +119,79 @@ Data directory: /nix/store/m0ns07v8by0458yp6k30rfq1rs3kaz6g-nix-2.21.2/share
|
118 | 119 | }
|
119 | 120 | }
|
120 | 121 |
|
121 |
| -func TestParseVersionInfoShort(t *testing.T) { |
122 |
| - info, err := parseVersionInfo([]byte("nix (Nix) 2.21.2")) |
| 122 | +func TestParseLixVersionInfo(t *testing.T) { |
| 123 | + raw := `nix (Lix, like Nix) 2.90.0-beta.1 |
| 124 | +System type: aarch64-darwin |
| 125 | +Additional system types: x86_64-darwin |
| 126 | +Features: gc, signed-caches |
| 127 | +System configuration file: /etc/nix/nix.conf |
| 128 | +User configuration files: /Users/nobody/.config/nix/nix.conf:/etc/xdg/nix/nix.conf |
| 129 | +Store directory: /nix/store |
| 130 | +State directory: /nix/var/nix |
| 131 | +Data directory: /nix/store/12asl5a17ffj78njcy2fj31v59rdmanx-lix-2.90-beta.1/share |
| 132 | +` |
| 133 | + |
| 134 | + info, err := parseVersionInfo([]byte(raw)) |
123 | 135 | if err != nil {
|
124 | 136 | t.Error("got parse error:", err)
|
125 | 137 | }
|
126 | 138 | if got, want := info.Name, "nix"; got != want {
|
127 | 139 | t.Errorf("got Name = %q, want %q", got, want)
|
128 | 140 | }
|
129 |
| - if got, want := info.Version, "2.21.2"; got != want { |
| 141 | + if got, want := info.Version, "2.90.0-beta.1"; got != want { |
130 | 142 | t.Errorf("got Version = %q, want %q", got, want)
|
131 | 143 | }
|
| 144 | + if got, want := info.System, "aarch64-darwin"; got != want { |
| 145 | + t.Errorf("got System = %q, want %q", got, want) |
| 146 | + } |
| 147 | + if got, want := info.ExtraSystems, []string{"x86_64-darwin"}; !slices.Equal(got, want) { |
| 148 | + t.Errorf("got ExtraSystems = %q, want %q", got, want) |
| 149 | + } |
| 150 | + if got, want := info.Features, []string{"gc", "signed-caches"}; !slices.Equal(got, want) { |
| 151 | + t.Errorf("got Features = %q, want %q", got, want) |
| 152 | + } |
| 153 | + if got, want := info.SystemConfig, "/etc/nix/nix.conf"; got != want { |
| 154 | + t.Errorf("got SystemConfig = %q, want %q", got, want) |
| 155 | + } |
| 156 | + if got, want := info.UserConfigs, []string{"/Users/nobody/.config/nix/nix.conf", "/etc/xdg/nix/nix.conf"}; !slices.Equal(got, want) { |
| 157 | + t.Errorf("got UserConfigs = %q, want %q", got, want) |
| 158 | + } |
| 159 | + if got, want := info.StoreDir, "/nix/store"; got != want { |
| 160 | + t.Errorf("got StoreDir = %q, want %q", got, want) |
| 161 | + } |
| 162 | + if got, want := info.StateDir, "/nix/var/nix"; got != want { |
| 163 | + t.Errorf("got StateDir = %q, want %q", got, want) |
| 164 | + } |
| 165 | + if got, want := info.DataDir, "/nix/store/12asl5a17ffj78njcy2fj31v59rdmanx-lix-2.90-beta.1/share"; got != want { |
| 166 | + t.Errorf("got DataDir = %q, want %q", got, want) |
| 167 | + } |
| 168 | +} |
| 169 | + |
| 170 | +func TestParseVersionInfoShort(t *testing.T) { |
| 171 | + cases := []struct { |
| 172 | + in string |
| 173 | + name string |
| 174 | + version string |
| 175 | + }{ |
| 176 | + {"nix (Nix) 2.21.2", "nix", "2.21.2"}, |
| 177 | + {"command (Nix) name (Nix) 2.21.2", "command (Nix) name", "2.21.2"}, |
| 178 | + {"nix (Lix, like Nix) 2.90.0-beta.1", "nix", "2.90.0-beta.1"}, |
| 179 | + } |
| 180 | + |
| 181 | + for _, tt := range cases { |
| 182 | + t.Run(tt.in, func(t *testing.T) { |
| 183 | + got, err := parseVersionInfo([]byte(tt.in)) |
| 184 | + if err != nil { |
| 185 | + t.Error("got parse error:", err) |
| 186 | + } |
| 187 | + if got.Name != tt.name { |
| 188 | + t.Errorf("got Name = %q, want %q", got.Name, tt.name) |
| 189 | + } |
| 190 | + if got.Version != tt.version { |
| 191 | + t.Errorf("got Version = %q, want %q", got.Version, tt.version) |
| 192 | + } |
| 193 | + }) |
| 194 | + } |
132 | 195 | }
|
133 | 196 |
|
134 | 197 | func TestParseVersionInfoError(t *testing.T) {
|
|
0 commit comments