| 867 | } |
| 868 | |
| 869 | func 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, |