| ... | ... |
@@ -201,17 +201,33 @@ func TestCommitRun(t *testing.T) {
|
| 201 | 201 |
} |
| 202 | 202 |
defer runtime.Destroy(container2) |
| 203 | 203 |
stdout, err := container2.StdoutPipe() |
| 204 |
+ if err != nil {
|
|
| 205 |
+ t.Fatal(err) |
|
| 206 |
+ } |
|
| 204 | 207 |
stderr, err := container2.StderrPipe() |
| 208 |
+ if err != nil {
|
|
| 209 |
+ t.Fatal(err) |
|
| 210 |
+ } |
|
| 205 | 211 |
if err := container2.Start(); err != nil {
|
| 206 | 212 |
t.Fatal(err) |
| 207 | 213 |
} |
| 208 | 214 |
container2.Wait() |
| 209 | 215 |
output, err := ioutil.ReadAll(stdout) |
| 216 |
+ if err != nil {
|
|
| 217 |
+ t.Fatal(err) |
|
| 218 |
+ } |
|
| 210 | 219 |
output2, err := ioutil.ReadAll(stderr) |
| 211 |
- stdout.Close() |
|
| 212 |
- stderr.Close() |
|
| 220 |
+ if err != nil {
|
|
| 221 |
+ t.Fatal(err) |
|
| 222 |
+ } |
|
| 223 |
+ if err := stdout.Close(); err != nil {
|
|
| 224 |
+ t.Fatal(err) |
|
| 225 |
+ } |
|
| 226 |
+ if err := stderr.Close(); err != nil {
|
|
| 227 |
+ t.Fatal(err) |
|
| 228 |
+ } |
|
| 213 | 229 |
if string(output) != "hello\n" {
|
| 214 |
- t.Fatalf("\nout: %s\nerr: %s\n", string(output), string(output2))
|
|
| 230 |
+ t.Fatalf("Unexpected output. Expected %s, received: %s (err: %s)", "hello\n", string(output), string(output2))
|
|
| 215 | 231 |
} |
| 216 | 232 |
} |
| 217 | 233 |
|
| ... | ... |
@@ -318,11 +334,9 @@ func TestExitCode(t *testing.T) {
|
| 318 | 318 |
defer nuke(runtime) |
| 319 | 319 |
|
| 320 | 320 |
trueContainer, err := runtime.Create(&Config{
|
| 321 |
- |
|
| 322 | 321 |
Image: GetTestImage(runtime).Id, |
| 323 | 322 |
Cmd: []string{"/bin/true", ""},
|
| 324 |
- }, |
|
| 325 |
- ) |
|
| 323 |
+ }) |
|
| 326 | 324 |
if err != nil {
|
| 327 | 325 |
t.Fatal(err) |
| 328 | 326 |
} |
| ... | ... |
@@ -330,12 +344,14 @@ func TestExitCode(t *testing.T) {
|
| 330 | 330 |
if err := trueContainer.Run(); err != nil {
|
| 331 | 331 |
t.Fatal(err) |
| 332 | 332 |
} |
| 333 |
+ if trueContainer.State.ExitCode != 0 {
|
|
| 334 |
+ t.Errorf("Unexpected exit code %d (expected 0)", trueContainer.State.ExitCode)
|
|
| 335 |
+ } |
|
| 333 | 336 |
|
| 334 | 337 |
falseContainer, err := runtime.Create(&Config{
|
| 335 | 338 |
Image: GetTestImage(runtime).Id, |
| 336 | 339 |
Cmd: []string{"/bin/false", ""},
|
| 337 |
- }, |
|
| 338 |
- ) |
|
| 340 |
+ }) |
|
| 339 | 341 |
if err != nil {
|
| 340 | 342 |
t.Fatal(err) |
| 341 | 343 |
} |
| ... | ... |
@@ -343,13 +359,8 @@ func TestExitCode(t *testing.T) {
|
| 343 | 343 |
if err := falseContainer.Run(); err != nil {
|
| 344 | 344 |
t.Fatal(err) |
| 345 | 345 |
} |
| 346 |
- |
|
| 347 |
- if trueContainer.State.ExitCode != 0 {
|
|
| 348 |
- t.Errorf("Unexpected exit code %v", trueContainer.State.ExitCode)
|
|
| 349 |
- } |
|
| 350 |
- |
|
| 351 | 346 |
if falseContainer.State.ExitCode != 1 {
|
| 352 |
- t.Errorf("Unexpected exit code %v", falseContainer.State.ExitCode)
|
|
| 347 |
+ t.Errorf("Unexpected exit code %d (expected 1)", falseContainer.State.ExitCode)
|
|
| 353 | 348 |
} |
| 354 | 349 |
} |
| 355 | 350 |
|
| ... | ... |
@@ -405,32 +416,62 @@ func TestRestartStdin(t *testing.T) {
|
| 405 | 405 |
defer runtime.Destroy(container) |
| 406 | 406 |
|
| 407 | 407 |
stdin, err := container.StdinPipe() |
| 408 |
+ if err != nil {
|
|
| 409 |
+ t.Fatal(err) |
|
| 410 |
+ } |
|
| 408 | 411 |
stdout, err := container.StdoutPipe() |
| 412 |
+ if err != nil {
|
|
| 413 |
+ t.Fatal(err) |
|
| 414 |
+ } |
|
| 409 | 415 |
if err := container.Start(); err != nil {
|
| 410 | 416 |
t.Fatal(err) |
| 411 | 417 |
} |
| 412 |
- io.WriteString(stdin, "hello world") |
|
| 413 |
- stdin.Close() |
|
| 418 |
+ if _, err := io.WriteString(stdin, "hello world"); err != nil {
|
|
| 419 |
+ t.Fatal(err) |
|
| 420 |
+ } |
|
| 421 |
+ if err := stdin.Close(); err != nil {
|
|
| 422 |
+ t.Fatal(err) |
|
| 423 |
+ } |
|
| 414 | 424 |
container.Wait() |
| 415 | 425 |
output, err := ioutil.ReadAll(stdout) |
| 416 |
- stdout.Close() |
|
| 426 |
+ if err != nil {
|
|
| 427 |
+ t.Fatal(err) |
|
| 428 |
+ } |
|
| 429 |
+ if err := stdout.Close(); err != nil {
|
|
| 430 |
+ t.Fatal(err) |
|
| 431 |
+ } |
|
| 417 | 432 |
if string(output) != "hello world" {
|
| 418 |
- t.Fatal(string(output)) |
|
| 433 |
+ t.Fatalf("Unexpected output. Expected %s, received: %s", "hello world", string(output))
|
|
| 419 | 434 |
} |
| 420 | 435 |
|
| 421 | 436 |
// Restart and try again |
| 422 | 437 |
stdin, err = container.StdinPipe() |
| 438 |
+ if err != nil {
|
|
| 439 |
+ t.Fatal(err) |
|
| 440 |
+ } |
|
| 423 | 441 |
stdout, err = container.StdoutPipe() |
| 442 |
+ if err != nil {
|
|
| 443 |
+ t.Fatal(err) |
|
| 444 |
+ } |
|
| 424 | 445 |
if err := container.Start(); err != nil {
|
| 425 | 446 |
t.Fatal(err) |
| 426 | 447 |
} |
| 427 |
- io.WriteString(stdin, "hello world #2") |
|
| 428 |
- stdin.Close() |
|
| 448 |
+ if _, err := io.WriteString(stdin, "hello world #2"); err != nil {
|
|
| 449 |
+ t.Fatal(err) |
|
| 450 |
+ } |
|
| 451 |
+ if err := stdin.Close(); err != nil {
|
|
| 452 |
+ t.Fatal(err) |
|
| 453 |
+ } |
|
| 429 | 454 |
container.Wait() |
| 430 | 455 |
output, err = ioutil.ReadAll(stdout) |
| 431 |
- stdout.Close() |
|
| 456 |
+ if err != nil {
|
|
| 457 |
+ t.Fatal(err) |
|
| 458 |
+ } |
|
| 459 |
+ if err := stdout.Close(); err != nil {
|
|
| 460 |
+ t.Fatal(err) |
|
| 461 |
+ } |
|
| 432 | 462 |
if string(output) != "hello world #2" {
|
| 433 |
- t.Fatal(string(output)) |
|
| 463 |
+ t.Fatalf("Unexpected output. Expected %s, received: %s", "hello world #2", string(output))
|
|
| 434 | 464 |
} |
| 435 | 465 |
} |
| 436 | 466 |
|
| ... | ... |
@@ -614,18 +655,31 @@ func TestStdin(t *testing.T) {
|
| 614 | 614 |
defer runtime.Destroy(container) |
| 615 | 615 |
|
| 616 | 616 |
stdin, err := container.StdinPipe() |
| 617 |
+ if err != nil {
|
|
| 618 |
+ t.Fatal(err) |
|
| 619 |
+ } |
|
| 617 | 620 |
stdout, err := container.StdoutPipe() |
| 621 |
+ if err != nil {
|
|
| 622 |
+ t.Fatal(err) |
|
| 623 |
+ } |
|
| 624 |
+ if err := container.Start(); err != nil {
|
|
| 625 |
+ t.Fatal(err) |
|
| 626 |
+ } |
|
| 618 | 627 |
defer stdin.Close() |
| 619 | 628 |
defer stdout.Close() |
| 620 |
- if err := container.Start(); err != nil {
|
|
| 629 |
+ if _, err := io.WriteString(stdin, "hello world"); err != nil {
|
|
| 630 |
+ t.Fatal(err) |
|
| 631 |
+ } |
|
| 632 |
+ if err := stdin.Close(); err != nil {
|
|
| 621 | 633 |
t.Fatal(err) |
| 622 | 634 |
} |
| 623 |
- io.WriteString(stdin, "hello world") |
|
| 624 |
- stdin.Close() |
|
| 625 | 635 |
container.Wait() |
| 626 | 636 |
output, err := ioutil.ReadAll(stdout) |
| 637 |
+ if err != nil {
|
|
| 638 |
+ t.Fatal(err) |
|
| 639 |
+ } |
|
| 627 | 640 |
if string(output) != "hello world" {
|
| 628 |
- t.Fatal(string(output)) |
|
| 641 |
+ t.Fatalf("Unexpected output. Expected %s, received: %s", "hello world", string(output))
|
|
| 629 | 642 |
} |
| 630 | 643 |
} |
| 631 | 644 |
|
| ... | ... |
@@ -648,18 +702,31 @@ func TestTty(t *testing.T) {
|
| 648 | 648 |
defer runtime.Destroy(container) |
| 649 | 649 |
|
| 650 | 650 |
stdin, err := container.StdinPipe() |
| 651 |
+ if err != nil {
|
|
| 652 |
+ t.Fatal(err) |
|
| 653 |
+ } |
|
| 651 | 654 |
stdout, err := container.StdoutPipe() |
| 655 |
+ if err != nil {
|
|
| 656 |
+ t.Fatal(err) |
|
| 657 |
+ } |
|
| 658 |
+ if err := container.Start(); err != nil {
|
|
| 659 |
+ t.Fatal(err) |
|
| 660 |
+ } |
|
| 652 | 661 |
defer stdin.Close() |
| 653 | 662 |
defer stdout.Close() |
| 654 |
- if err := container.Start(); err != nil {
|
|
| 663 |
+ if _, err := io.WriteString(stdin, "hello world"); err != nil {
|
|
| 664 |
+ t.Fatal(err) |
|
| 665 |
+ } |
|
| 666 |
+ if err := stdin.Close(); err != nil {
|
|
| 655 | 667 |
t.Fatal(err) |
| 656 | 668 |
} |
| 657 |
- io.WriteString(stdin, "hello world") |
|
| 658 |
- stdin.Close() |
|
| 659 | 669 |
container.Wait() |
| 660 | 670 |
output, err := ioutil.ReadAll(stdout) |
| 671 |
+ if err != nil {
|
|
| 672 |
+ t.Fatal(err) |
|
| 673 |
+ } |
|
| 661 | 674 |
if string(output) != "hello world" {
|
| 662 |
- t.Fatal(string(output)) |
|
| 675 |
+ t.Fatalf("Unexpected output. Expected %s, received: %s", "hello world", string(output))
|
|
| 663 | 676 |
} |
| 664 | 677 |
} |
| 665 | 678 |
|
| ... | ... |
@@ -678,6 +745,7 @@ func TestEnv(t *testing.T) {
|
| 678 | 678 |
t.Fatal(err) |
| 679 | 679 |
} |
| 680 | 680 |
defer runtime.Destroy(container) |
| 681 |
+ |
|
| 681 | 682 |
stdout, err := container.StdoutPipe() |
| 682 | 683 |
if err != nil {
|
| 683 | 684 |
t.Fatal(err) |