MCPcopy Index your code
hub / github.com/docker/docker-agent / TestBuildModelChain

Function TestBuildModelChain

pkg/runtime/fallback_test.go:64–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62)
63
64func TestBuildModelChain(t *testing.T) {
65 t.Parallel()
66
67 primary := &mockProvider{id: "primary/model"}
68 fallback1 := &mockProvider{id: "fallback/model1"}
69 fallback2 := &mockProvider{id: "fallback/model2"}
70
71 t.Run("no fallbacks", func(t *testing.T) {
72 t.Parallel()
73 chain := buildModelChain(primary, nil)
74 require.Len(t, chain, 1)
75 assert.Equal(t, primary.ID().String(), chain[0].provider.ID().String())
76 assert.False(t, chain[0].isFallback)
77 assert.Equal(t, -1, chain[0].index)
78 })
79
80 t.Run("with fallbacks", func(t *testing.T) {
81 t.Parallel()
82 chain := buildModelChain(primary, []provider.Provider{fallback1, fallback2})
83 require.Len(t, chain, 3)
84
85 assert.Equal(t, primary.ID().String(), chain[0].provider.ID().String())
86 assert.False(t, chain[0].isFallback)
87
88 assert.Equal(t, fallback1.ID().String(), chain[1].provider.ID().String())
89 assert.True(t, chain[1].isFallback)
90 assert.Equal(t, 0, chain[1].index)
91
92 assert.Equal(t, fallback2.ID().String(), chain[2].provider.ID().String())
93 assert.True(t, chain[2].isFallback)
94 assert.Equal(t, 1, chain[2].index)
95 })
96}
97
98func TestFallbackOrder(t *testing.T) {
99 t.Parallel()

Callers

nothing calls this directly

Calls 6

IDMethod · 0.95
buildModelChainFunction · 0.85
RunMethod · 0.65
LenMethod · 0.65
IDMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected