Skip to content

Commit 66a456c

Browse files
committed
Add unit test readme
1 parent 9ff3fd8 commit 66a456c

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

scripts/apitypings/main.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,6 @@ func (g *Generator) buildStruct(obj types.Object, st *types.Struct) (string, err
510510
return data.String(), nil
511511
}
512512

513-
c := TypescriptType {
514-
ValueType: "comparable",
515-
GenericValue: "C",
516-
GenericTypes: map[string]string{
517-
"C":"comparable"
518-
}
519-
}
520-
521513
type TypescriptType struct {
522514
// GenericTypes is a map of generic name to actual constraint.
523515
// We return these, so we can bubble them up if we are recursively traversing
@@ -543,7 +535,7 @@ type TypescriptType struct {
543535
GenericValue string
544536
// ValueType is the typescript value type. This is the actual type or
545537
// generic constraint. This can **always** be used without special handling.
546-
ValueType string
538+
ValueType string
547539
// AboveTypeLine lets you put whatever text you want above the typescript
548540
// type line.
549541
AboveTypeLine string

scripts/apitypings/testdata/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# How to add a unit test
2+
3+
1. Create a new directory in `testdata`
4+
2. Name a go file `<directory_name>.go`. This file will generate the typescript.
5+
3. Name the expected typescript file `<directory_name>.ts`. This is the unit test's expected output.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package enums
2+
3+
type Enum string
4+
5+
const (
6+
EnumFoo Enum = "foo"
7+
EnumBar Enum = "bar"
8+
EnumBaz Enum = "baz"
9+
EnumQux Enum = "qux"
10+
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Code generated by 'make coder/scripts/apitypings/main.go'. DO NOT EDIT.
2+
3+
// From codersdk/enums.go
4+
export type Enum = "bar" | "baz" | "foo" | "qux"

0 commit comments

Comments
 (0)