dockerversion: add a basic unit-test
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c679da9ae1
commit
eb9a5392bc
1 changed files with 24 additions and 0 deletions
24
dockerversion/useragent_test.go
Normal file
24
dockerversion/useragent_test.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package dockerversion
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
||||
func TestDockerUserAgent(t *testing.T) {
|
||||
t.Run("daemon user-agent", func(t *testing.T) {
|
||||
ua := DockerUserAgent(context.TODO())
|
||||
expected := getDaemonUserAgent()
|
||||
assert.Check(t, is.Equal(ua, expected))
|
||||
})
|
||||
|
||||
t.Run("daemon user-agent with upstream", func(t *testing.T) {
|
||||
ctx := context.WithValue(context.TODO(), UAStringKey{}, "Magic-Client/1.2.3 (linux)")
|
||||
ua := DockerUserAgent(ctx)
|
||||
expected := getDaemonUserAgent() + ` UpstreamClient(Magic-Client/1.2.3 \(linux\))`
|
||||
assert.Check(t, is.Equal(ua, expected))
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue