mirror of
https://github.com/docker/compose.git
synced 2026-11-18 06:07:53 +00:00
Before this, assertion libraries were mixed, sometimes
even in the same file.
git grep -l '"gotest.tools/v3/' | wc -l
75
git grep -l '"github.com/stretchr/testify' | wc -l
24
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
/*
|
|
Copyright 2024 Docker Compose CLI authors
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package tracing
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/compose-spec/compose-go/v2/types"
|
|
"gotest.tools/v3/assert"
|
|
)
|
|
|
|
func TestProjectHash(t *testing.T) {
|
|
projA := &types.Project{
|
|
Name: "fake-proj",
|
|
WorkingDir: "/tmp",
|
|
Services: map[string]types.ServiceConfig{
|
|
"foo": {Image: "fake-image"},
|
|
},
|
|
DisabledServices: map[string]types.ServiceConfig{
|
|
"bar": {Image: "diff-image"},
|
|
},
|
|
}
|
|
projB := &types.Project{
|
|
Name: "fake-proj",
|
|
WorkingDir: "/tmp",
|
|
Services: map[string]types.ServiceConfig{
|
|
"foo": {Image: "fake-image"},
|
|
"bar": {Image: "diff-image"},
|
|
},
|
|
}
|
|
projC := &types.Project{
|
|
Name: "fake-proj",
|
|
WorkingDir: "/tmp",
|
|
Services: map[string]types.ServiceConfig{
|
|
"foo": {Image: "fake-image"},
|
|
"bar": {Image: "diff-image"},
|
|
"baz": {Image: "yet-another-image"},
|
|
},
|
|
}
|
|
|
|
hashA, ok := projectHash(projA)
|
|
assert.Assert(t, ok)
|
|
assert.Assert(t, hashA != "")
|
|
hashB, ok := projectHash(projB)
|
|
assert.Assert(t, ok)
|
|
assert.Assert(t, hashB != "")
|
|
assert.Equal(t, hashA, hashB)
|
|
|
|
hashC, ok := projectHash(projC)
|
|
assert.Assert(t, ok)
|
|
assert.Assert(t, hashC != "")
|
|
assert.Assert(t, hashC != hashA)
|
|
}
|