MCPcopy Create free account
hub / github.com/docker/buildx / TestReadContextFromTargetChain

Function TestReadContextFromTargetChain

bake/bake_test.go:923–964  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

921}
922
923func TestReadContextFromTargetChain(t *testing.T) {
924 ctx := context.TODO()
925 fp := File{
926 Name: "docker-bake.hcl",
927 Data: []byte(`
928 target "base" {
929 }
930 target "mid" {
931 output = ["foo"]
932 contexts = {
933 parent: "target:base"
934 }
935 }
936 target "app" {
937 contexts = {
938 foo: "baz"
939 bar: "target:mid"
940 }
941 }
942 target "unused" {}
943 `),
944 }
945
946 m, _, err := ReadTargets(ctx, []File{fp}, []string{"app"}, []string{}, nil, nil, &EntitlementConf{})
947 require.NoError(t, err)
948
949 require.Equal(t, 3, len(m))
950 app, ok := m["app"]
951 require.True(t, ok)
952
953 require.Equal(t, 2, len(app.Contexts))
954
955 mid, ok := m["mid"]
956 require.True(t, ok)
957 require.Equal(t, 1, len(mid.Outputs))
958 require.Equal(t, "type=cacheonly", mid.Outputs[0].String())
959 require.Equal(t, 1, len(mid.Contexts))
960
961 base, ok := m["base"]
962 require.True(t, ok)
963 require.Equal(t, 0, len(base.Contexts))
964}
965
966func TestReadContextFromTargetInfiniteLoop(t *testing.T) {
967 ctx := context.TODO()

Callers

nothing calls this directly

Calls 3

ReadTargetsFunction · 0.85
EqualMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…