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

Function TestGenerateFromPrompt

coderd/taskname/taskname_internal_test.go:28–119  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func TestGenerateFromPrompt(t *testing.T) {
29 t.Parallel()
30
31 tests := []struct {
32 name string
33 prompt string
34 expectError bool
35 expectedName string
36 expectedDisplayName string
37 }{
38 {
39 name: "EmptyPrompt",
40 prompt: "",
41 expectError: true,
42 },
43 {
44 name: "OnlySpaces",
45 prompt: " ",
46 expectError: true,
47 },
48 {
49 name: "OnlySpecialCharacters",
50 prompt: "!@#$%^&*()",
51 expectError: true,
52 },
53 {
54 name: "UppercasePrompt",
55 prompt: "BUILD MY APP",
56 expectError: false,
57 expectedName: "build-my-app",
58 expectedDisplayName: "BUILD MY APP",
59 },
60 {
61 name: "PromptWithApostrophes",
62 prompt: "fix user's dashboard",
63 expectError: false,
64 expectedName: "fix-users-dashboard",
65 expectedDisplayName: "Fix user's dashboard",
66 },
67 {
68 name: "LongPrompt",
69 prompt: strings.Repeat("a", 100),
70 expectError: false,
71 expectedName: strings.Repeat("a", 27),
72 expectedDisplayName: "A" + strings.Repeat("a", 62) + "…",
73 },
74 {
75 name: "PromptWithMultipleSpaces",
76 prompt: "build my app",
77 expectError: false,
78 expectedName: "build-my-app",
79 expectedDisplayName: "Build my app",
80 },
81 {
82 name: "PromptWithNewlines",
83 prompt: "build\nmy\napp",
84 expectError: false,
85 expectedName: "build-my-app",

Callers

nothing calls this directly

Calls 7

NameValidFunction · 0.92
generateFromPromptFunction · 0.85
NotEmptyMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45
ContainsMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected