mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-18 06:29:42 +02:00
Feat/auto schemas (#48)
* use auto generated schemas * go version bump and dependencies upgrade * clarify some error messages --------- Co-authored-by: yusing <yusing@6uo.me>
This commit is contained in:
43
internal/docker/container_test.go
Normal file
43
internal/docker/container_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
. "github.com/yusing/go-proxy/internal/utils/testing"
|
||||
)
|
||||
|
||||
func TestContainerExplicit(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
labels map[string]string
|
||||
isExplicit bool
|
||||
}{
|
||||
{
|
||||
name: "explicit",
|
||||
labels: map[string]string{
|
||||
"proxy.aliases": "foo",
|
||||
},
|
||||
isExplicit: true,
|
||||
},
|
||||
{
|
||||
name: "explicit2",
|
||||
labels: map[string]string{
|
||||
"proxy.idle_timeout": "1s",
|
||||
},
|
||||
isExplicit: true,
|
||||
},
|
||||
{
|
||||
name: "not explicit",
|
||||
labels: map[string]string{},
|
||||
isExplicit: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
c := FromDocker(&types.Container{Names: []string{"test"}, State: "test", Labels: tt.labels}, "")
|
||||
ExpectEqual(t, c.IsExplicit, tt.isExplicit)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -294,6 +294,9 @@ func (w *Watcher) watchUntilDestroy() (returnCause error) {
|
||||
case errors.Is(err, context.Canceled):
|
||||
continue
|
||||
case err != nil:
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
err = errors.New("timeout waiting for container to stop, please set a higher value for `stop_timeout`")
|
||||
}
|
||||
w.Err(err).Msgf("container stop with method %q failed", w.StopMethod)
|
||||
default:
|
||||
w.LogReason("container stopped", "idle timeout")
|
||||
|
||||
Reference in New Issue
Block a user