Skip to content

Commit 3d6c11a

Browse files
committed
Address review
1 parent e6644a8 commit 3d6c11a

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

pkg/board/os_image.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,10 @@ func parseOSImageVersion(r io.Reader) (string, bool) {
6767
return "", false
6868
}
6969

70-
type OSImageRelease struct {
71-
VersionLabel string
72-
ID string
73-
Latest bool
74-
}
75-
7670
// Calculates whether user partition preservation is supported,
7771
// according to the current and target OS image versions.
7872
//
7973
// Preservation is supported if both versions are not the R0 image.
80-
func IsUserPartitionPreservationSupported(conn remote.RemoteConn, targetImageVersion OSImageRelease) bool {
81-
currentImageVersion := GetOSImageVersion(conn)
82-
return targetImageVersion.ID != R0_IMAGE_VERSION_ID && currentImageVersion != R0_IMAGE_VERSION_ID
74+
func IsUserPartitionPreservationSupported(currentImageVersion string, targetImageVersion string) bool {
75+
return targetImageVersion != R0_IMAGE_VERSION_ID && currentImageVersion != R0_IMAGE_VERSION_ID
8376
}

pkg/board/os_image_test.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,45 +112,43 @@ func TestGetOSImageVersion(t *testing.T) {
112112

113113
func TestIsUserPartitionPreservationSupported(t *testing.T) {
114114
const R0_IMAGE_VERSION_ID = "20250807-136"
115-
116-
R0Version := createBuildInfoConnection(R0_IMAGE_VERSION_ID)
117-
AnotherVersion := createBuildInfoConnection("BUILD_ID=20250101-001")
115+
anotherVersionId := "20250101-001"
118116

119117
tests := []struct {
120118
name string
121-
currentVersion remote.RemoteConn
119+
currentVersion string
122120
targetVersion string
123121
isPreservationSupported bool
124122
}{
125123
{
126124
name: "both versions are *not* R0",
127-
currentVersion: AnotherVersion,
125+
currentVersion: anotherVersionId,
128126
targetVersion: "20250101-001",
129127
isPreservationSupported: true,
130128
},
131129
{
132130
name: "current version is R0",
133-
currentVersion: R0Version,
131+
currentVersion: R0_IMAGE_VERSION_ID,
134132
targetVersion: "20250101-001",
135133
isPreservationSupported: false,
136134
},
137135
{
138136
name: "target version is R0",
139-
currentVersion: AnotherVersion,
137+
currentVersion: anotherVersionId,
140138
targetVersion: R0_IMAGE_VERSION_ID,
141139
isPreservationSupported: false,
142140
},
143141
{
144142
name: "both versions are R0",
145-
currentVersion: R0Version,
143+
currentVersion: R0_IMAGE_VERSION_ID,
146144
targetVersion: R0_IMAGE_VERSION_ID,
147145
isPreservationSupported: false,
148146
},
149147
}
150148

151149
for _, tt := range tests {
152150
t.Run(tt.name, func(t *testing.T) {
153-
isPreservationSupported := IsUserPartitionPreservationSupported(tt.currentVersion, OSImageRelease{ID: tt.targetVersion})
151+
isPreservationSupported := IsUserPartitionPreservationSupported(tt.currentVersion, tt.targetVersion)
154152
require.Equal(t, isPreservationSupported, tt.isPreservationSupported)
155153
})
156154
}

0 commit comments

Comments
 (0)