()
| 724 | } |
| 725 | |
| 726 | func ExampleContainer_Host() { |
| 727 | ctx := context.Background() |
| 728 | |
| 729 | nginxC, err := Run(ctx, nginxAlpineImage, |
| 730 | WithExposedPorts("80/tcp"), |
| 731 | WithWaitStrategy(wait.ForHTTP("/").WithStartupTimeout(10*time.Second)), |
| 732 | ) |
| 733 | defer func() { |
| 734 | if err := TerminateContainer(nginxC); err != nil { |
| 735 | log.Printf("failed to terminate container: %s", err) |
| 736 | } |
| 737 | }() |
| 738 | if err != nil { |
| 739 | log.Printf("failed to create container: %s", err) |
| 740 | return |
| 741 | } |
| 742 | // containerHost { |
| 743 | ip, err := nginxC.Host(ctx) |
| 744 | if err != nil { |
| 745 | log.Printf("failed to create container: %s", err) |
| 746 | return |
| 747 | } |
| 748 | // } |
| 749 | fmt.Println(ip) |
| 750 | |
| 751 | state, err := nginxC.State(ctx) |
| 752 | if err != nil { |
| 753 | log.Printf("failed to get container state: %s", err) |
| 754 | return |
| 755 | } |
| 756 | |
| 757 | fmt.Println(state.Running) |
| 758 | |
| 759 | // Output: |
| 760 | // localhost |
| 761 | // true |
| 762 | } |
| 763 | |
| 764 | func ExampleContainer_Start() { |
| 765 | ctx := context.Background() |
nothing calls this directly
no test coverage detected
searching dependent graphs…