(t *testing.T)
| 73 | } |
| 74 | |
| 75 | func TestKillSignal(t *testing.T) { |
| 76 | const serviceName = "service1" |
| 77 | mockCtrl := gomock.NewController(t) |
| 78 | defer mockCtrl.Finish() |
| 79 | |
| 80 | api, cli := prepareMocks(mockCtrl) |
| 81 | tested, err := NewComposeService(cli) |
| 82 | assert.NilError(t, err) |
| 83 | |
| 84 | name := strings.ToLower(testProject) |
| 85 | listOptions := client.ContainerListOptions{ |
| 86 | Filters: projectFilter(name).Add("label", serviceFilter(serviceName), compose.ConfigHashLabel), |
| 87 | } |
| 88 | |
| 89 | api.EXPECT().ContainerList(t.Context(), listOptions).Return(client.ContainerListResult{ |
| 90 | Items: []container.Summary{testContainer(serviceName, "123", false)}, |
| 91 | }, nil) |
| 92 | api.EXPECT().VolumeList( |
| 93 | gomock.Any(), |
| 94 | client.VolumeListOptions{ |
| 95 | Filters: projectFilter(strings.ToLower(testProject)), |
| 96 | }). |
| 97 | Return(client.VolumeListResult{}, nil) |
| 98 | api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: projectFilter(strings.ToLower(testProject))}). |
| 99 | Return(client.NetworkListResult{ |
| 100 | Items: []network.Summary{{ |
| 101 | Network: network.Network{ID: "abc123", Name: "testProject_default"}, |
| 102 | }}, |
| 103 | }, nil) |
| 104 | api.EXPECT().ContainerKill(anyCancellableContext(), "123", client.ContainerKillOptions{ |
| 105 | Signal: "SIGTERM", |
| 106 | }).Return(client.ContainerKillResult{}, nil) |
| 107 | |
| 108 | err = tested.Kill(t.Context(), name, compose.KillOptions{Services: []string{serviceName}, Signal: "SIGTERM"}) |
| 109 | assert.NilError(t, err) |
| 110 | } |
| 111 | |
| 112 | func testContainer(service string, id string, oneOff bool) container.Summary { |
| 113 | // canonical docker names in the API start with a leading slash, some |
nothing calls this directly
no test coverage detected