MCPcopy Index your code
hub / github.com/coder/coder / requirePromptItemReferenceOrder

Function requirePromptItemReferenceOrder

coderd/x/chatd/integration_responses_test.go:633–661  ·  view source on GitHub ↗
(
	t *testing.T,
	prompt []interface{},
	firstID string,
	secondID string,
)

Source from the content-addressed store, hash-verified

631}
632
633func requirePromptItemReferenceOrder(
634 t *testing.T,
635 prompt []interface{},
636 firstID string,
637 secondID string,
638) {
639 t.Helper()
640 firstIndex := -1
641 secondIndex := -1
642 for index, item := range prompt {
643 itemMap, ok := item.(map[string]interface{})
644 if !ok {
645 continue
646 }
647 itemID := chattest.StringResponseField(itemMap, "id")
648 if itemID == "" {
649 itemID = chattest.StringResponseField(itemMap, "item_id")
650 }
651 switch itemID {
652 case firstID:
653 firstIndex = index
654 case secondID:
655 secondIndex = index
656 }
657 }
658 require.NotEqual(t, -1, firstIndex, "missing first item reference")
659 require.NotEqual(t, -1, secondIndex, "missing second item reference")
660 require.Less(t, firstIndex, secondIndex)
661}

Calls 3

StringResponseFieldFunction · 0.92
LessMethod · 0.80
HelperMethod · 0.65

Tested by

no test coverage detected