-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e26d2a
commit e52283e
Showing
3 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* Copyright (c) [2024] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import * as model from "~/storage/model/config/drive"; | ||
|
||
describe("#generate", () => { | ||
it("returns a drive object from a drive section", () => { | ||
expect(model.generate( | ||
undefined, | ||
{ | ||
search: "/dev/vda", | ||
alias: "test", | ||
filesystem: { | ||
type: "xfs", | ||
path: "/test" | ||
} | ||
} | ||
)).toEqual( | ||
{ | ||
name: "/dev/vda", | ||
alias: "test", | ||
filesystem: "xfs", | ||
mountPath: "/test", | ||
snapshots: undefined, | ||
spacePolicy: undefined | ||
} | ||
); | ||
|
||
expect(model.generate( | ||
{ | ||
partitions: [ | ||
{ search: "*", delete: true } | ||
] | ||
}, | ||
{ | ||
search: "/dev/vda", | ||
alias: "test", | ||
filesystem: { | ||
type: { | ||
btrfs: { snapshots: false } | ||
}, | ||
path: "/test" | ||
} | ||
} | ||
)).toEqual( | ||
{ | ||
name: "/dev/vda", | ||
alias: "test", | ||
filesystem: "btrfs", | ||
mountPath: "/test", | ||
snapshots: false, | ||
spacePolicy: "delete" | ||
} | ||
); | ||
|
||
expect(model.generate( | ||
{ | ||
partitions: [ | ||
{ search: "*", delete: true }, | ||
{ generate: "default" } | ||
] | ||
}, | ||
{ | ||
search: "/dev/vda", | ||
partitions: [ | ||
{ search: "/dev/vda1", delete: true }, | ||
{ filesystem: { path: "/" } } | ||
] | ||
} | ||
)).toEqual( | ||
{ | ||
name: "/dev/vda", | ||
alias: undefined, | ||
spacePolicy: "delete", | ||
partitions: [ | ||
{ | ||
name: "/dev/vda1", | ||
delete: true | ||
}, | ||
{ | ||
name: undefined, | ||
alias: undefined, | ||
filesystem: undefined, | ||
mountPath: "/", | ||
snapshots: undefined, | ||
size: undefined | ||
} | ||
] | ||
} | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) [2024] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import * as model from "~/storage/model/config/partition"; | ||
|
||
describe("#generate", () => { | ||
it("returns a partition object from a partition section", () => { | ||
expect(model.generate( | ||
{ | ||
search: "/dev/vda1", | ||
delete: true | ||
} | ||
)).toEqual( | ||
{ | ||
name: "/dev/vda1", | ||
delete: true | ||
} | ||
); | ||
|
||
expect(model.generate( | ||
{ | ||
search: "/dev/vda1", | ||
deleteIfNeeded: true, | ||
size: 1024 | ||
} | ||
)).toEqual( | ||
{ | ||
name: "/dev/vda1", | ||
deleteIfNeeded: true, | ||
size: { min: 1024, max: 1024 } | ||
} | ||
); | ||
|
||
expect(model.generate( | ||
{ | ||
search: "/dev/vda1", | ||
alias: "test", | ||
filesystem: { | ||
path: "/test", | ||
type: { | ||
btrfs: { snapshots: true } | ||
} | ||
}, | ||
size: { min: 0, max: 2048 } | ||
} | ||
)).toEqual( | ||
{ | ||
name: "/dev/vda1", | ||
alias: "test", | ||
filesystem: "btrfs", | ||
mountPath: "/test", | ||
snapshots: true, | ||
size: { min: 0, max: 2048 } | ||
} | ||
); | ||
|
||
expect(model.generate( | ||
{ | ||
filesystem: { | ||
path: "/test", | ||
} | ||
} | ||
)).toEqual( | ||
{ | ||
name: undefined, | ||
alias: undefined, | ||
filesystem: undefined, | ||
mountPath: "/test", | ||
snapshots: undefined, | ||
size: undefined | ||
} | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters