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

Function TestCoderHeaders

coderd/x/chatd/chatprovider/chatprovider_test.go:781–851  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

779}
780
781func TestCoderHeaders(t *testing.T) {
782 t.Parallel()
783
784 t.Run("RootChatNoWorkspace", func(t *testing.T) {
785 t.Parallel()
786 chatID := uuid.New()
787 ownerID := uuid.New()
788 chat := database.Chat{
789 ID: chatID,
790 OwnerID: ownerID,
791 }
792 h := chatprovider.CoderHeaders(chat)
793 require.Equal(t, ownerID.String(), h[chatprovider.HeaderCoderOwnerID])
794 require.Equal(t, chatID.String(), h[chatprovider.HeaderCoderChatID])
795 require.NotContains(t, h, chatprovider.HeaderCoderSubchatID)
796 require.NotContains(t, h, chatprovider.HeaderCoderWorkspaceID)
797 })
798
799 t.Run("RootChatWithWorkspace", func(t *testing.T) {
800 t.Parallel()
801 chatID := uuid.New()
802 ownerID := uuid.New()
803 workspaceID := uuid.New()
804 chat := database.Chat{
805 ID: chatID,
806 OwnerID: ownerID,
807 WorkspaceID: uuid.NullUUID{UUID: workspaceID, Valid: true},
808 }
809 h := chatprovider.CoderHeaders(chat)
810 require.Equal(t, ownerID.String(), h[chatprovider.HeaderCoderOwnerID])
811 require.Equal(t, chatID.String(), h[chatprovider.HeaderCoderChatID])
812 require.NotContains(t, h, chatprovider.HeaderCoderSubchatID)
813 require.Equal(t, workspaceID.String(), h[chatprovider.HeaderCoderWorkspaceID])
814 })
815
816 t.Run("SubchatWithWorkspace", func(t *testing.T) {
817 t.Parallel()
818 parentID := uuid.New()
819 subchatID := uuid.New()
820 ownerID := uuid.New()
821 workspaceID := uuid.New()
822 chat := database.Chat{
823 ID: subchatID,
824 OwnerID: ownerID,
825 ParentChatID: uuid.NullUUID{UUID: parentID, Valid: true},
826 WorkspaceID: uuid.NullUUID{UUID: workspaceID, Valid: true},
827 }
828 h := chatprovider.CoderHeaders(chat)
829 require.Equal(t, ownerID.String(), h[chatprovider.HeaderCoderOwnerID])
830 require.Equal(t, parentID.String(), h[chatprovider.HeaderCoderChatID])
831 require.Equal(t, subchatID.String(), h[chatprovider.HeaderCoderSubchatID])
832 require.Equal(t, workspaceID.String(), h[chatprovider.HeaderCoderWorkspaceID])
833 })
834
835 t.Run("SubchatNoWorkspace", func(t *testing.T) {
836 t.Parallel()
837 parentID := uuid.New()
838 subchatID := uuid.New()

Callers

nothing calls this directly

Calls 5

CoderHeadersFunction · 0.92
RunMethod · 0.65
NewMethod · 0.65
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected