Переглянути джерело

Merge pull request #7251 from tiborvass/fix-test-import-display

Fix test import display
Victor Vieux 11 роки тому
батько
коміт
487a417d9f

+ 2 - 2
integration-cli/docker_cli_import_test.go

@@ -12,8 +12,8 @@ func TestImportDisplay(t *testing.T) {
 	out, _, err := runCommandWithOutput(importCmd)
 	out, _, err := runCommandWithOutput(importCmd)
 	errorOut(err, t, fmt.Sprintf("import failed with errors: %v", err))
 	errorOut(err, t, fmt.Sprintf("import failed with errors: %v", err))
 
 
-	if n := len(strings.Split(out, "\n")); n != 3 {
-		t.Fatalf("display is messed up: %d '\\n' instead of 3", n)
+	if n := strings.Count(out, "\n"); n != 2 {
+		t.Fatalf("display is messed up: %d '\\n' instead of 2", n)
 	}
 	}
 
 
 	logDone("import - cirros was imported and display is fine")
 	logDone("import - cirros was imported and display is fine")

+ 0 - 2
server/server.go

@@ -1701,8 +1701,6 @@ func (srv *Server) ImageImport(job *engine.Job) engine.Status {
 			u.Path = ""
 			u.Path = ""
 		}
 		}
 		job.Stdout.Write(sf.FormatStatus("", "Downloading from %s", u))
 		job.Stdout.Write(sf.FormatStatus("", "Downloading from %s", u))
-		// Download with curl (pretty progress bar)
-		// If curl is not available, fallback to http.Get()
 		resp, err = utils.Download(u.String())
 		resp, err = utils.Download(u.String())
 		if err != nil {
 		if err != nil {
 			return job.Error(err)
 			return job.Error(err)

+ 1 - 1
utils/progressreader.go

@@ -32,7 +32,7 @@ func (r *progressReader) Read(p []byte) (n int, err error) {
 		r.lastUpdate = r.progress.Current
 		r.lastUpdate = r.progress.Current
 	}
 	}
 	// Send newline when complete
 	// Send newline when complete
-	if r.newLine && err != nil {
+	if r.newLine && err != nil && read == 0 {
 		r.output.Write(r.sf.FormatStatus("", ""))
 		r.output.Write(r.sf.FormatStatus("", ""))
 	}
 	}
 	return read, err
 	return read, err