mirror of
https://github.com/moby/buildkit.git
synced 2026-08-06 07:40:49 +00:00
add unit test for getmount output index
Signed-off-by: Cory Bennett <cbennett@netflix.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/moby/buildkit/solver/pb"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -25,3 +26,27 @@ func TestTmpfsMountError(t *testing.T) {
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), "must use scratch")
|
||||
}
|
||||
|
||||
func TestValidGetMountIndex(t *testing.T) {
|
||||
// tests for https://github.com/moby/buildkit/issues/1520
|
||||
|
||||
// tmpfs mount /c will sort later than target mount /b, /b will have output index==1
|
||||
st := Image("foo").Run(Shlex("args"), AddMount("/b", Scratch()), AddMount("/c", Scratch(), Tmpfs())).GetMount("/b")
|
||||
|
||||
mountOutput, ok := st.Output().(*output)
|
||||
require.True(t, ok, "mount output is expected type")
|
||||
|
||||
mountIndex, err := mountOutput.getIndex()
|
||||
require.NoError(t, err, "failed to getIndex")
|
||||
require.Equal(t, pb.OutputIndex(1), mountIndex, "unexpected mount index")
|
||||
|
||||
// now swapping so the tmpfs mount /a will sort earlier than the target mount /b, /b should still have output index==1
|
||||
st = Image("foo").Run(Shlex("args"), AddMount("/b", Scratch()), AddMount("/a", Scratch(), Tmpfs())).GetMount("/b")
|
||||
|
||||
mountOutput, ok = st.Output().(*output)
|
||||
require.True(t, ok, "mount output is expected type")
|
||||
|
||||
mountIndex, err = mountOutput.getIndex()
|
||||
require.NoError(t, err, "failed to getIndex")
|
||||
require.Equal(t, pb.OutputIndex(1), mountIndex, "unexpected mount index")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user