Skip to content

Commit

Permalink
fixed some go vet issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsmedina committed Nov 30, 2013
1 parent 82cecb3 commit a6c9a33
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 52 deletions.
84 changes: 42 additions & 42 deletions archive/changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func TestChangesDirsMutated(t *testing.T) {
}
if changes[i].Path == expectedChanges[i].Path {
if changes[i] != expectedChanges[i] {
t.Fatalf("Wrong change for %s, expected %s, got %d\n", changes[i].Path, changes[i].String(), expectedChanges[i].String())
t.Fatalf("Wrong change for %s, expected %s, got %s\n", changes[i].Path, changes[i].String(), expectedChanges[i].String())
}
} else if changes[i].Path < expectedChanges[i].Path {
t.Fatalf("unexpected change %s\n", changes[i].String())
Expand All @@ -261,45 +261,45 @@ func TestApplyLayer(t *testing.T) {
t.Skip("Skipping TestApplyLayer due to known failures") // Disable this for now as it is broken
return

src, err := ioutil.TempDir("", "docker-changes-test")
if err != nil {
t.Fatal(err)
}
createSampleDir(t, src)
dst := src + "-copy"
if err := copyDir(src, dst); err != nil {
t.Fatal(err)
}
mutateSampleDir(t, dst)

changes, err := ChangesDirs(dst, src)
if err != nil {
t.Fatal(err)
}

layer, err := ExportChanges(dst, changes)
if err != nil {
t.Fatal(err)
}

layerCopy, err := NewTempArchive(layer, "")
if err != nil {
t.Fatal(err)
}

if err := ApplyLayer(src, layerCopy); err != nil {
t.Fatal(err)
}

changes2, err := ChangesDirs(src, dst)
if err != nil {
t.Fatal(err)
}

if len(changes2) != 0 {
t.Fatalf("Unexpected differences after re applying mutation: %v", changes)
}

os.RemoveAll(src)
os.RemoveAll(dst)
// src, err := ioutil.TempDir("", "docker-changes-test")
// if err != nil {
// t.Fatal(err)
// }
// createSampleDir(t, src)
// dst := src + "-copy"
// if err := copyDir(src, dst); err != nil {
// t.Fatal(err)
// }
// mutateSampleDir(t, dst)

// changes, err := ChangesDirs(dst, src)
// if err != nil {
// t.Fatal(err)
// }

// layer, err := ExportChanges(dst, changes)
// if err != nil {
// t.Fatal(err)
// }

// layerCopy, err := NewTempArchive(layer, "")
// if err != nil {
// t.Fatal(err)
// }

// if err := ApplyLayer(src, layerCopy); err != nil {
// t.Fatal(err)
// }

// changes2, err := ChangesDirs(src, dst)
// if err != nil {
// t.Fatal(err)
// }

// if len(changes2) != 0 {
// t.Fatalf("Unexpected differences after re applying mutation: %v", changes)
// }

// os.RemoveAll(src)
// os.RemoveAll(dst)
}
6 changes: 3 additions & 3 deletions engine/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ func TestSetenvBool(t *testing.T) {
job := mkJob(t, "dummy")
job.SetenvBool("foo", true)
if val := job.GetenvBool("foo"); !val {
t.Fatalf("GetenvBool returns incorrect value: %b", val)
t.Fatalf("GetenvBool returns incorrect value: %t", val)
}

job.SetenvBool("bar", false)
if val := job.GetenvBool("bar"); val {
t.Fatalf("GetenvBool returns incorrect value: %b", val)
t.Fatalf("GetenvBool returns incorrect value: %t", val)
}

if val := job.GetenvBool("nonexistent"); val {
t.Fatalf("GetenvBool returns incorrect value: %b", val)
t.Fatalf("GetenvBool returns incorrect value: %t", val)
}
}

Expand Down
6 changes: 3 additions & 3 deletions graphdriver/devmapper/deviceset.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (devices *DeviceSet) saveMetadata() error {
return fmt.Errorf("Error closing metadata file %s: %s", tmpFile.Name(), err)
}
if err := osRename(tmpFile.Name(), devices.jsonFile()); err != nil {
return fmt.Errorf("Error committing metadata file", err)
return fmt.Errorf("Error committing metadata file %s: %s", tmpFile.Name(), err)
}

if devices.NewTransactionId != devices.TransactionId {
Expand Down Expand Up @@ -439,11 +439,11 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error {
hasMetadata := devices.hasImage("metadata")

if !doInit && !hasData {
return fmt.Errorf("Looback data file not found %s")
return fmt.Error("Looback data file not found")
}

if !doInit && !hasMetadata {
return fmt.Errorf("Looback metadata file not found %s")
return fmt.Error("Looback metadata file not found")
}

createdLoopback := !hasData || !hasMetadata
Expand Down
4 changes: 2 additions & 2 deletions integration/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func setupBaseImage() {
job.SetenvBool("Autorestart", false)
job.Setenv("BridgeIface", unitTestNetworkBridge)
if err := job.Run(); err != nil {
log.Fatalf("Unable to create a runtime for tests:", err)
log.Fatalf("Unable to create a runtime for tests: %s", err)
}
srv := mkServerFromEngine(eng, log.New(os.Stderr, "", 0))

Expand Down Expand Up @@ -173,7 +173,7 @@ func spawnGlobalDaemon() {
func GetTestImage(runtime *docker.Runtime) *docker.Image {
imgs, err := runtime.Graph().Map()
if err != nil {
log.Fatalf("Unable to get the test image:", err)
log.Fatalf("Unable to get the test image: %s", err)
}
for _, image := range imgs {
if image.ID == unitTestImageID {
Expand Down
2 changes: 1 addition & 1 deletion network.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ type Nat struct {
}

func (n *Nat) String() string {
return fmt.Sprintf("%s:%d:%d/%s", n.Binding.HostIp, n.Binding.HostPort, n.Port.Port(), n.Port.Proto())
return fmt.Sprintf("%s:%s:%s/%s", n.Binding.HostIp, n.Binding.HostPort, n.Port.Port(), n.Port.Proto())
}

// Release: Network cleanup - release all resources
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ func (srv *Server) recursiveLoad(address, tmpImageDir string) error {

imageJson, err := ioutil.ReadFile(path.Join(tmpImageDir, "repo", address, "json"))
if err != nil {
return err
utils.Debugf("Error reading json", err)
return err
}

layer, err := os.Open(path.Join(tmpImageDir, "repo", address, "layer.tar"))
Expand Down

0 comments on commit a6c9a33

Please sign in to comment.