Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Commit

Permalink
add test for version filling in recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
datacharmer committed Mar 31, 2019
1 parent 2da652b commit db330ef
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions cookbook/recipes_test.go
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)
}

0 comments on commit db330ef

Please sign in to comment.