This repository has been archived by the owner on Oct 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for version filling in recipes
- Loading branch information
1 parent
2da652b
commit db330ef
Showing
1 changed file
with
54 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,54 @@ | ||
// DBDeployer - The MySQL Sandbox | ||
// Copyright © 2006-2019 Giuseppe Maxia | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package cookbook | ||
|
||
import ( | ||
"fmt" | ||
"github.com/datacharmer/dbdeployer/common" | ||
"github.com/datacharmer/dbdeployer/compare" | ||
"github.com/datacharmer/dbdeployer/sandbox" | ||
"testing" | ||
) | ||
|
||
func TestGetLatestVersion(t *testing.T) { | ||
err := sandbox.SetMockEnvironment(sandbox.DefaultMockDir) | ||
if err != nil { | ||
t.Fatal("mock dir creation failed") | ||
} | ||
compare.OkIsNil("creating mock environment", err, t) | ||
var versions = []string{ | ||
"5.0.89", | ||
"5.1.67", | ||
"5.5.48", | ||
"5.6.78", | ||
"5.7.22", | ||
"8.0.11", | ||
} | ||
latest := GetLatestVersion("", common.MySQLFlavor) | ||
compare.OkMatchesString("latest version", latest, `NOTFOUND`, t) | ||
recipe, _, _ := GetRecipe("single", common.MySQLFlavor) | ||
compare.OkMatchesString("recipe single", recipe, "NOTFOUND", t) | ||
for _, version := range versions { | ||
err = sandbox.CreateMockVersion(version) | ||
compare.OkIsNil(fmt.Sprintf("creating mock version %s", version), err, t) | ||
latest := GetLatestVersion("", common.MySQLFlavor) | ||
compare.OkEqualString("latest version", latest, version, t) | ||
recipe, _, _ = GetRecipe("single", common.MySQLFlavor) | ||
compare.OkMatchesString("recipe single", recipe, version, t) | ||
} | ||
|
||
err = sandbox.RemoveMockEnvironment(sandbox.DefaultMockDir) | ||
compare.OkIsNil("removing mock environment", err, t) | ||
} |