-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test case for unshare and show minimum coverage
Signed-off-by: nitin sanghi <er.nitin.sanghi@gmail.com>
- Loading branch information
1 parent
81937f7
commit 125e16f
Showing
4 changed files
with
69 additions
and
1 deletion.
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
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
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,35 @@ | ||
package supermarket | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/chef/go-chef-cli/core" | ||
) | ||
|
||
func TestCookbookShow(t *testing.T) { | ||
|
||
var config core.Config | ||
var ui core.UI | ||
|
||
rescueStdout := os.Stdout | ||
r, w, _ := os.Pipe() | ||
os.Stdout = w | ||
ShowCookBook("mysql", "https://supermarket.chef.io", ui, config, "8.5.1") | ||
w.Close() | ||
out, _ := ioutil.ReadAll(r) | ||
os.Stdout = rescueStdout | ||
data := string(out) | ||
if !strings.Contains(data, "https://supermarket.chef.io/api/v1/cookbooks/mysql") { | ||
t.Error("not valid output for mysql") | ||
} | ||
if !strings.Contains(data, "https://supermarket.chef.io/api/v1/cookbooks/mysql") { | ||
t.Error("not valid output for mysql") | ||
} | ||
if !strings.Contains(data, "2017-08-23T19:01:28Z") { | ||
t.Error("not valid output for mysql") | ||
} | ||
|
||
} |
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,29 @@ | ||
package supermarket | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/chef/go-chef-cli/core" | ||
"github.com/go-chef/chef" | ||
) | ||
|
||
func TestCookbookUnshare(t *testing.T) { | ||
|
||
var config core.Config | ||
var ui core.UI | ||
|
||
homeDir, _ := os.UserHomeDir() | ||
data, path := config.LoadConfig(homeDir + "/.chef/") | ||
var cc chef.ConfigRb | ||
cc, err := chef.NewClientRb(data, path) | ||
if err != nil { | ||
ui.Fatal("No knife configuration file found. See https://docs.chef.io/config_rb/ for details.") | ||
} | ||
err = UnShareCookbook("mysql", "https://supermarket.chef.io", cc.NodeName, cc.ClientKey) | ||
|
||
if err == nil { | ||
t.Error("not valid output for mysql") | ||
} | ||
|
||
} |