pkg/utils, test/system: Add some more tests for parsing Fedora releases
https://github.com/containers/toolbox/pull/1262
This commit is contained in:
parent
1c320b0eb0
commit
e01927bfdc
2 changed files with 121 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2021 – 2022 Red Hat Inc.
|
||||
* Copyright © 2021 – 2023 Red Hat Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -95,11 +95,51 @@ func TestParseRelease(t *testing.T) {
|
|||
inputRelease: "-3",
|
||||
errMsg: "The release must be a positive integer.",
|
||||
},
|
||||
{
|
||||
inputDistro: "fedora",
|
||||
inputRelease: "-3.0",
|
||||
errMsg: "The release must be a positive integer.",
|
||||
},
|
||||
{
|
||||
inputDistro: "fedora",
|
||||
inputRelease: "-3.1",
|
||||
errMsg: "The release must be a positive integer.",
|
||||
},
|
||||
{
|
||||
inputDistro: "fedora",
|
||||
inputRelease: "0",
|
||||
errMsg: "The release must be a positive integer.",
|
||||
},
|
||||
{
|
||||
inputDistro: "fedora",
|
||||
inputRelease: "0.0",
|
||||
errMsg: "The release must be a positive integer.",
|
||||
},
|
||||
{
|
||||
inputDistro: "fedora",
|
||||
inputRelease: "0.1",
|
||||
errMsg: "The release must be a positive integer.",
|
||||
},
|
||||
{
|
||||
inputDistro: "fedora",
|
||||
inputRelease: "3.0",
|
||||
errMsg: "The release must be a positive integer.",
|
||||
},
|
||||
{
|
||||
inputDistro: "fedora",
|
||||
inputRelease: "3.1",
|
||||
errMsg: "The release must be a positive integer.",
|
||||
},
|
||||
{
|
||||
inputDistro: "fedora",
|
||||
inputRelease: "foo",
|
||||
errMsg: "The release must be a positive integer.",
|
||||
},
|
||||
{
|
||||
inputDistro: "fedora",
|
||||
inputRelease: "3foo",
|
||||
errMsg: "The release must be a positive integer.",
|
||||
},
|
||||
{
|
||||
inputDistro: "rhel",
|
||||
inputRelease: "8.3",
|
||||
|
|
|
@ -130,6 +130,76 @@ teardown() {
|
|||
assert [ ${#lines[@]} -eq 3 ]
|
||||
}
|
||||
|
||||
@test "create: Try '--distro fedora --release -3.0'" {
|
||||
run $TOOLBOX --assumeyes create --distro fedora --release -3.0
|
||||
|
||||
assert_failure
|
||||
assert_line --index 0 "Error: invalid argument for '--release'"
|
||||
assert_line --index 1 "The release must be a positive integer."
|
||||
assert_line --index 2 "Run 'toolbox --help' for usage."
|
||||
assert [ ${#lines[@]} -eq 3 ]
|
||||
}
|
||||
|
||||
@test "create: Try '--distro fedora --release -3.1'" {
|
||||
run $TOOLBOX --assumeyes create --distro fedora --release -3.1
|
||||
|
||||
assert_failure
|
||||
assert_line --index 0 "Error: invalid argument for '--release'"
|
||||
assert_line --index 1 "The release must be a positive integer."
|
||||
assert_line --index 2 "Run 'toolbox --help' for usage."
|
||||
assert [ ${#lines[@]} -eq 3 ]
|
||||
}
|
||||
|
||||
@test "create: Try '--distro fedora --release 0'" {
|
||||
run $TOOLBOX --assumeyes create --distro fedora --release 0
|
||||
|
||||
assert_failure
|
||||
assert_line --index 0 "Error: invalid argument for '--release'"
|
||||
assert_line --index 1 "The release must be a positive integer."
|
||||
assert_line --index 2 "Run 'toolbox --help' for usage."
|
||||
assert [ ${#lines[@]} -eq 3 ]
|
||||
}
|
||||
|
||||
@test "create: Try '--distro fedora --release 0.0'" {
|
||||
run $TOOLBOX --assumeyes create --distro fedora --release 0.0
|
||||
|
||||
assert_failure
|
||||
assert_line --index 0 "Error: invalid argument for '--release'"
|
||||
assert_line --index 1 "The release must be a positive integer."
|
||||
assert_line --index 2 "Run 'toolbox --help' for usage."
|
||||
assert [ ${#lines[@]} -eq 3 ]
|
||||
}
|
||||
|
||||
@test "create: Try '--distro fedora --release 0.1'" {
|
||||
run $TOOLBOX --assumeyes create --distro fedora --release 0.1
|
||||
|
||||
assert_failure
|
||||
assert_line --index 0 "Error: invalid argument for '--release'"
|
||||
assert_line --index 1 "The release must be a positive integer."
|
||||
assert_line --index 2 "Run 'toolbox --help' for usage."
|
||||
assert [ ${#lines[@]} -eq 3 ]
|
||||
}
|
||||
|
||||
@test "create: Try '--distro fedora --release 3.0'" {
|
||||
run $TOOLBOX --assumeyes create --distro fedora --release 3.0
|
||||
|
||||
assert_failure
|
||||
assert_line --index 0 "Error: invalid argument for '--release'"
|
||||
assert_line --index 1 "The release must be a positive integer."
|
||||
assert_line --index 2 "Run 'toolbox --help' for usage."
|
||||
assert [ ${#lines[@]} -eq 3 ]
|
||||
}
|
||||
|
||||
@test "create: Try '--distro fedora --release 3.1'" {
|
||||
run $TOOLBOX --assumeyes create --distro fedora --release 3.1
|
||||
|
||||
assert_failure
|
||||
assert_line --index 0 "Error: invalid argument for '--release'"
|
||||
assert_line --index 1 "The release must be a positive integer."
|
||||
assert_line --index 2 "Run 'toolbox --help' for usage."
|
||||
assert [ ${#lines[@]} -eq 3 ]
|
||||
}
|
||||
|
||||
@test "create: Try '--distro fedora --release foo'" {
|
||||
run $TOOLBOX --assumeyes create --distro fedora --release foo
|
||||
|
||||
|
@ -140,6 +210,16 @@ teardown() {
|
|||
assert [ ${#lines[@]} -eq 3 ]
|
||||
}
|
||||
|
||||
@test "create: Try '--distro fedora --release 3foo'" {
|
||||
run $TOOLBOX --assumeyes create --distro fedora --release 3foo
|
||||
|
||||
assert_failure
|
||||
assert_line --index 0 "Error: invalid argument for '--release'"
|
||||
assert_line --index 1 "The release must be a positive integer."
|
||||
assert_line --index 2 "Run 'toolbox --help' for usage."
|
||||
assert [ ${#lines[@]} -eq 3 ]
|
||||
}
|
||||
|
||||
@test "create: Try '--distro rhel --release 8'" {
|
||||
run $TOOLBOX --assumeyes create --distro rhel --release 8
|
||||
|
||||
|
|
Loading…
Reference in a new issue