Repository: istio/istio
File: pkg/kube/krt/conformance_test.go (Go)

Code before:
			}
			fc.RunAndWait(test.NewStop(t))
			return rig
		}
		runConformance[*corev1.ConfigMap](t, factory)
	})
	t.Run("static list", func(t *testing.T) {
		factory := func(t *testing.T) Rig[Named] {
			col := krt.NewStaticCollection[Named](nil, nil, krt.WithStop(test.NewStop(t)), krt.WithDebugging(krt.GlobalDebugHandler), krt.WithMetadata(metadata))
			rig := &staticRig{
				StaticCollection: col,
			}
			return rig
		}
		runConformance[Named](t, factory)
	})
	t.Run("static singleton", func(t *testing.T) {
		factory := func(t *testing.T) Rig[Named] {
			singleton := krt.NewStatic[Named](nil, true, krt.WithStop(test.NewStop(t)), krt.WithDebugging(krt.GlobalDebugHandler), krt.WithMetadata(metadata))
			rig := &staticSingletonRig{
				Collection: singleton.AsCollection(),
				singleton:  singleton,
			}
			return rig
		}
		// this can't handle lists
		runReplaceConformance[Named](t, factory(t))
	})
	t.Run("join", func(t *testing.T) {
		factory := func(t *testing.T) Rig[Named] {
			col1 := krt.NewStaticCollection[Named](nil, nil, krt.WithStop(test.NewStop(t)), krt.WithDebugging(krt.GlobalDebugHandler))
			col2 := krt.NewStaticCollection[Named](nil, nil, krt.WithStop(test.NewStop(t)), krt.WithDebugging(krt.GlobalDebugHandler))
			j := krt.JoinCollection(
				[]krt.Collection[Named]{col1, col2},
				krt.WithStop(test.NewStop(t)),
				krt.WithDebugging(krt.GlobalDebugHandler),
				krt.WithMetadata(metadata),
			)
			rig := &joinRig{
				Collection: j,
				inner:      [2]krt.StaticCollection[Named]{col1, col2},
			}
			return rig
		}
		runConformance[Named](t, factory)
	})
	t.Run("manyCollection", func(t *testing.T) {
		factory := func(t *testing.T) Rig[Named] {
			namespaces := krt.NewStaticCollection[string](nil, nil, krt.WithStop(test.NewStop(t)), krt.WithDebugging(krt.GlobalDebugHandler))
			names := krt.NewStaticCollection[string](nil, nil, krt.WithStop(test.NewStop(t)), krt.WithDebugging(krt.GlobalDebugHandler))
			col := krt.NewManyCollection(namespaces, func(ctx krt.HandlerContext, ns string) []Named {

Review comment (suggestion):
Comment is a bit confusing: it can handle List()s but it can't handle having a second item added (which full conformance does).

Code after:
			}
			fc.RunAndWait(test.NewStop(t))
			return rig
		}
		runConformance[*corev1.ConfigMap](t, factory)
	})
	t.Run("static list", func(t *testing.T) {
		factory := func(t *testing.T) Rig[Named] {
			col := krt.NewStaticCollection[Named](nil, nil, krt.WithStop(test.NewStop(t)), krt.WithDebugging(krt.GlobalDebugHandler), krt.WithMetadata(metadata))
			rig := &staticRig{
				StaticCollection: col,
			}
			return rig
		}
		runConformance[Named](t, factory)
	})
	t.Run("static singleton", func(t *testing.T) {
		factory := func(t *testing.T) Rig[Named] {
			singleton := krt.NewStatic[Named](nil, true, krt.WithStop(test.NewStop(t)), krt.WithDebugging(krt.GlobalDebugHandler), krt.WithMetadata(metadata))
			rig := &staticSingletonRig{
				Collection: singleton.AsCollection(),
				singleton:  singleton,
			}
			return rig
		}
		// singleton only holds one item, so skip full conformance which adds multiple items
		runReplaceConformance[Named](t, factory(t))
	})
	t.Run("join", func(t *testing.T) {
		factory := func(t *testing.T) Rig[Named] {
			col1 := krt.NewStaticCollection[Named](nil, nil,
				krt.WithStop(test.NewStop(t)),
				krt.WithDebugging(krt.GlobalDebugHandler),
				krt.WithName("join-conformance-1"))
			col2 := krt.NewStaticCollection[Named](nil, nil,
				krt.WithStop(test.NewStop(t)),
				krt.WithDebugging(krt.GlobalDebugHandler),
				krt.WithName("join-conformance-2"))
			j := krt.JoinCollection(
				[]krt.Collection[Named]{col1, col2},
				krt.WithStop(test.NewStop(t)),
				krt.WithDebugging(krt.GlobalDebugHandler),
				krt.WithMetadata(metadata),
			)
			rig := &joinRig{
				Collection: j,
				inner:      [2]krt.StaticCollection[Named]{col1, col2},
			}
			return rig
		}
		runConformance[Named](t, factory)