2014-02-25 11:17:48 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// search for repos named "registry" on the central registry
|
|
|
|
func TestSearchOnCentralRegistry(t *testing.T) {
|
2015-03-25 23:44:09 -04:00
|
|
|
testRequires(t, Network)
|
2014-08-19 12:52:46 -04:00
|
|
|
searchCmd := exec.Command(dockerBinary, "search", "busybox")
|
2014-02-25 11:17:48 -05:00
|
|
|
out, exitCode, err := runCommandWithOutput(searchCmd)
|
|
|
|
if err != nil || exitCode != 0 {
|
2014-11-05 11:26:22 -05:00
|
|
|
t.Fatalf("failed to search on the central registry: %s, %v", out, err)
|
2014-02-25 11:17:48 -05:00
|
|
|
}
|
|
|
|
|
2014-06-24 17:16:34 -04:00
|
|
|
if !strings.Contains(out, "Busybox base image.") {
|
|
|
|
t.Fatal("couldn't find any repository named (or containing) 'Busybox base image.'")
|
2014-02-25 11:17:48 -05:00
|
|
|
}
|
|
|
|
|
2014-06-24 17:16:34 -04:00
|
|
|
logDone("search - search for repositories named (or containing) 'Busybox base image.'")
|
2014-02-25 11:17:48 -05:00
|
|
|
}
|
2015-04-02 20:55:08 -04:00
|
|
|
|
|
|
|
func TestSearchStarsOptionWithWrongParameter(t *testing.T) {
|
|
|
|
searchCmdStarsChars := exec.Command(dockerBinary, "search", "--stars=a", "busybox")
|
|
|
|
out, exitCode, err := runCommandWithOutput(searchCmdStarsChars)
|
|
|
|
if err == nil || exitCode == 0 {
|
|
|
|
t.Fatalf("Should not get right information: %s, %v", out, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.Contains(out, "invalid value") {
|
|
|
|
t.Fatal("couldn't find the invalid value warning")
|
|
|
|
}
|
|
|
|
|
|
|
|
searchCmdStarsNegativeNumber := exec.Command(dockerBinary, "search", "-s=-1", "busybox")
|
|
|
|
out, exitCode, err = runCommandWithOutput(searchCmdStarsNegativeNumber)
|
|
|
|
if err == nil || exitCode == 0 {
|
|
|
|
t.Fatalf("Should not get right information: %s, %v", out, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.Contains(out, "invalid value") {
|
|
|
|
t.Fatal("couldn't find the invalid value warning")
|
|
|
|
}
|
|
|
|
|
|
|
|
logDone("search - Verify search with wrong parameter.")
|
|
|
|
}
|