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

Function TestSearchTemplates

coderd/searchquery/search_test.go:869–1021  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

867}
868
869func TestSearchTemplates(t *testing.T) {
870 t.Parallel()
871 userID := uuid.New()
872 testCases := []struct {
873 Name string
874 Query string
875 Expected database.GetTemplatesWithFilterParams
876 ExpectedErrorContains string
877 }{
878 {
879 Name: "Empty",
880 Query: "",
881 Expected: database.GetTemplatesWithFilterParams{},
882 },
883 {
884 Name: "OnlyName",
885 Query: "foobar",
886 Expected: database.GetTemplatesWithFilterParams{
887 FuzzyDisplayName: "foobar",
888 },
889 },
890 {
891 Name: "HasAITaskTrue",
892 Query: "has-ai-task:true",
893 Expected: database.GetTemplatesWithFilterParams{
894 HasAITask: sql.NullBool{
895 Bool: true,
896 Valid: true,
897 },
898 },
899 },
900 {
901 Name: "HasAITaskFalse",
902 Query: "has-ai-task:false",
903 Expected: database.GetTemplatesWithFilterParams{
904 HasAITask: sql.NullBool{
905 Bool: false,
906 Valid: true,
907 },
908 },
909 },
910 {
911 Name: "HasAITaskMissing",
912 Query: "",
913 Expected: database.GetTemplatesWithFilterParams{
914 HasAITask: sql.NullBool{
915 Bool: false,
916 Valid: false,
917 },
918 },
919 },
920 {
921 Name: "HasExternalAgent",
922 Query: "has_external_agent:true",
923 Expected: database.GetTemplatesWithFilterParams{
924 HasExternalAgent: sql.NullBool{
925 Bool: true,
926 Valid: true,

Callers

nothing calls this directly

Calls 9

NewDBFunction · 0.92
TemplatesFunction · 0.92
WriteStringMethod · 0.80
NewMethod · 0.65
RunMethod · 0.65
ContainsMethod · 0.45
StringMethod · 0.45
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected