From 3e0f3ca0c4612c7cf2b6ccdc5e680cea7c7bd649 Mon Sep 17 00:00:00 2001 From: Svetlin Ralchev Date: Thu, 12 Dec 2019 18:25:10 +0000 Subject: [PATCH] Generate spec for each controller --- syntax/golang/dom.go | 11 + syntax/golang/generator_controller.go | 35 +- template/resource.go | 406 +++++++++++++---------- template/syntax/golang/spec.go.tpl | 38 +++ template/syntax/golang/spec_suite.go.tpl | 13 + 5 files changed, 331 insertions(+), 172 deletions(-) create mode 100644 template/syntax/golang/spec.go.tpl create mode 100644 template/syntax/golang/spec_suite.go.tpl diff --git a/syntax/golang/dom.go b/syntax/golang/dom.go index 212c63c..430dae2 100644 --- a/syntax/golang/dom.go +++ b/syntax/golang/dom.go @@ -169,6 +169,17 @@ func (f *File) WriteTo(w io.Writer) (int64, error) { return int64(n), err } +// ReadFrom reads the content from a file +func (f *File) ReadFrom(r io.Reader) (int64, error) { + node, err := decorator.Parse(r) + if err != nil { + return 0, err + } + + f.node = node + return 0, nil +} + // AddNode adds a node to the file func (f *File) AddNode(node Node) { f.node.Decls = append(f.node.Decls, node.Node()) diff --git a/syntax/golang/generator_controller.go b/syntax/golang/generator_controller.go index 0723a39..da8bc96 100644 --- a/syntax/golang/generator_controller.go +++ b/syntax/golang/generator_controller.go @@ -3,6 +3,7 @@ package golang import ( "bytes" "fmt" + "go/build" "net/http" "path/filepath" "strings" @@ -295,12 +296,42 @@ func (g *ControllerGenerator) controller(root *File) { "summary": operation.Summary, "deprecated": operation.DeprecationMessage(), }) - } } func (g *ControllerGenerator) spec(root *File) { - //TODO: + g.Reporter.Error("ﳑ Generating tests: %s...", root.Name()) + + project, err := filepath.Rel(filepath.Join(build.Default.GOPATH, "src"), g.Path) + if err != nil { + g.Reporter.Error(" Generating markdown documentation fail: ", err) + return + } + + ctx := map[string]interface{}{ + "receiver": inflect.Camelize(g.Controller.Name) + "API", + "project": project, + "operations": g.Controller.Operations, + } + + writer := &syntax.TemplateWriter{ + Path: "syntax/golang/spec.go.tpl", + Context: ctx, + } + + buffer := &bytes.Buffer{} + + if _, err := writer.WriteTo(buffer); err != nil { + g.Reporter.Error("ﳑ Generating tests: %s fail: %v", root.Name(), err) + return + } + + if _, err := root.ReadFrom(buffer); err != nil { + g.Reporter.Error("ﳑ Generating tests: %s fail: %v", root.Name(), err) + return + } + + g.Reporter.Success("ﳑ Generating tests: %s success", root.Name()) } func (g *ControllerGenerator) function(root *File, name string, ctx map[string]interface{}) { diff --git a/template/resource.go b/template/resource.go index 60ac935..2d1056d 100644 --- a/template/resource.go +++ b/template/resource.go @@ -344656,86 +344656,140 @@ func init() { 84, 182, 106, 193, 251, 36, 31, 127, 69, 29, 70, 24, 216, 94, 94, 198, 44, 255, 4, 0, 0, 255, 255, 80, 75, 7, 8, 74, 45, 168, 124, 177, 1, 0, 0, 139, 3, 0, 0, 80, 75, 3, 4, 20, - 0, 8, 0, 8, 0, 142, 186, 134, 79, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 27, 0, 9, 0, 115, 121, 110, 116, 97, 120, 47, - 103, 111, 108, 97, 110, 103, 47, 115, 116, 97, 116, 117, 115, - 46, 103, 111, 46, 116, 112, 108, 85, 84, 5, 0, 1, 61, 226, - 234, 93, 116, 143, 177, 78, 196, 48, 16, 68, 235, 243, 87, - 140, 92, 37, 72, 112, 125, 122, 90, 40, 224, 7, 140, 61, 7, - 22, 231, 245, 201, 222, 32, 130, 241, 191, 35, 19, 10, 40, - 104, 119, 231, 105, 222, 180, 118, 13, 159, 83, 162, 40, 236, - 131, 58, 93, 43, 10, 117, 45, 82, 225, 4, 47, 170, 23, 212, - 253, 236, 115, 160, 69, 239, 230, 15, 83, 181, 196, 192, 229, - 153, 194, 226, 148, 22, 211, 43, 55, 220, 20, 122, 198, 55, - 150, 17, 24, 180, 157, 7, 121, 90, 197, 99, 122, 199, 85, - 107, 191, 34, 159, 240, 46, 241, 28, 63, 136, 222, 103, 236, - 22, 211, 140, 40, 138, 102, 14, 199, 35, 126, 74, 2, 79, 81, - 136, 167, 28, 182, 165, 170, 43, 250, 253, 188, 187, 127, - 188, 93, 32, 89, 17, 211, 229, 204, 161, 197, 240, 31, 70, - 9, 230, 176, 15, 196, 144, 24, 163, 134, 89, 55, 95, 1, 0, - 0, 255, 255, 80, 75, 7, 8, 64, 116, 193, 223, 173, 0, 0, 0, - 10, 1, 0, 0, 80, 75, 3, 4, 20, 0, 8, 0, 8, 0, 93, 40, 140, - 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 0, 9, 0, 115, - 121, 110, 116, 97, 120, 47, 109, 97, 114, 107, 100, 111, 119, - 110, 47, 114, 101, 97, 100, 109, 101, 46, 109, 100, 46, 116, - 112, 108, 85, 84, 5, 0, 1, 2, 202, 241, 93, 148, 85, 221, - 110, 27, 55, 19, 189, 231, 83, 12, 108, 1, 95, 20, 68, 187, - 240, 119, 41, 32, 64, 227, 58, 85, 250, 99, 200, 72, 221, - 139, 66, 40, 98, 106, 57, 218, 157, 136, 203, 217, 114, 184, - 187, 81, 19, 191, 123, 65, 82, 242, 42, 128, 91, 164, 87, - 162, 102, 135, 156, 115, 206, 156, 33, 47, 225, 243, 103, - 40, 2, 5, 139, 240, 248, 168, 84, 252, 103, 80, 42, 79, 93, - 32, 118, 41, 246, 230, 238, 71, 24, 208, 11, 177, 91, 166, - 244, 227, 159, 244, 241, 242, 242, 18, 214, 3, 250, 129, 112, - 84, 234, 190, 33, 1, 65, 63, 160, 135, 81, 11, 212, 232, 208, - 235, 128, 6, 182, 7, 216, 72, 240, 100, 240, 143, 23, 77, - 8, 157, 44, 203, 178, 166, 208, 244, 219, 162, 226, 182, 236, - 26, 174, 217, 234, 173, 148, 57, 105, 14, 157, 231, 143, 88, - 133, 2, 114, 141, 59, 143, 30, 255, 236, 73, 40, 160, 82, - 191, 115, 15, 210, 112, 111, 13, 52, 122, 64, 8, 13, 194, - 142, 173, 229, 145, 92, 13, 129, 217, 10, 144, 147, 160, 173, - 69, 179, 84, 106, 1, 155, 21, 91, 237, 234, 169, 248, 56, - 142, 69, 157, 98, 5, 251, 122, 14, 113, 213, 235, 26, 225, - 133, 14, 96, 81, 75, 56, 145, 134, 171, 226, 234, 255, 115, - 165, 94, 222, 234, 61, 130, 244, 62, 214, 211, 33, 21, 69, - 55, 144, 103, 215, 162, 11, 48, 104, 79, 122, 107, 17, 30, - 86, 235, 187, 55, 247, 239, 30, 32, 137, 17, 10, 184, 111, - 206, 130, 134, 60, 86, 129, 253, 65, 141, 100, 45, 108, 17, - 122, 65, 3, 90, 96, 100, 191, 151, 78, 87, 56, 229, 192, 142, - 61, 104, 107, 97, 181, 62, 41, 34, 197, 203, 44, 201, 10, - 67, 136, 116, 127, 13, 218, 7, 52, 74, 209, 14, 14, 220, 67, - 195, 146, 193, 9, 247, 190, 66, 168, 216, 32, 176, 131, 154, - 2, 104, 103, 98, 142, 63, 29, 6, 141, 22, 208, 208, 121, 26, - 116, 64, 48, 216, 161, 51, 232, 42, 66, 81, 135, 73, 228, - 138, 221, 142, 234, 200, 60, 109, 142, 39, 85, 150, 34, 233, - 192, 17, 126, 138, 116, 158, 3, 87, 108, 11, 248, 129, 125, - 150, 223, 85, 177, 47, 94, 173, 40, 188, 235, 183, 9, 84, - 197, 109, 27, 81, 36, 9, 13, 163, 228, 213, 177, 208, 22, - 151, 74, 61, 60, 60, 168, 89, 46, 146, 234, 194, 98, 81, 91, - 222, 106, 11, 189, 183, 197, 69, 77, 225, 187, 201, 58, 203, - 139, 34, 150, 66, 109, 214, 59, 184, 120, 198, 90, 23, 233, - 60, 21, 123, 112, 78, 15, 180, 71, 104, 181, 211, 117, 118, - 103, 246, 199, 255, 68, 109, 90, 54, 189, 69, 121, 214, 167, - 217, 49, 101, 205, 229, 72, 123, 42, 111, 115, 234, 124, 58, - 249, 0, 114, 144, 128, 109, 166, 177, 213, 210, 168, 25, 224, - 167, 142, 125, 128, 213, 250, 234, 234, 234, 118, 125, 243, - 219, 47, 111, 95, 179, 155, 226, 119, 239, 215, 63, 189, 253, - 254, 254, 195, 221, 207, 171, 215, 113, 190, 78, 189, 121, - 124, 84, 51, 168, 12, 204, 178, 117, 74, 241, 85, 57, 59, - 75, 142, 34, 49, 212, 24, 160, 40, 139, 162, 200, 60, 163, - 51, 222, 247, 206, 165, 65, 104, 16, 2, 74, 144, 76, 191, - 211, 213, 94, 215, 40, 209, 151, 49, 140, 6, 200, 169, 205, - 245, 205, 205, 196, 21, 93, 17, 153, 117, 104, 72, 199, 193, - 200, 60, 175, 177, 209, 3, 177, 95, 24, 79, 3, 186, 15, 6, - 7, 180, 220, 69, 219, 207, 65, 194, 193, 98, 106, 186, 74, - 173, 236, 122, 223, 177, 224, 43, 24, 49, 137, 220, 75, 196, - 178, 89, 145, 219, 215, 156, 43, 45, 203, 146, 157, 80, 113, - 84, 150, 184, 172, 211, 215, 114, 30, 29, 170, 54, 43, 110, - 177, 214, 255, 152, 155, 190, 150, 243, 39, 66, 69, 190, 17, - 42, 237, 78, 83, 159, 102, 134, 119, 81, 129, 54, 118, 23, - 63, 97, 213, 135, 147, 38, 211, 85, 113, 116, 163, 124, 213, - 174, 163, 168, 103, 109, 143, 0, 78, 16, 243, 207, 191, 164, - 37, 116, 79, 166, 115, 105, 38, 35, 52, 223, 187, 4, 43, 117, + 0, 8, 0, 8, 0, 249, 146, 140, 79, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 25, 0, 9, 0, 115, 121, 110, 116, 97, 120, 47, + 103, 111, 108, 97, 110, 103, 47, 115, 112, 101, 99, 46, 103, + 111, 46, 116, 112, 108, 85, 84, 5, 0, 1, 183, 133, 242, 93, + 164, 145, 65, 111, 219, 62, 12, 197, 207, 210, 167, 32, 114, + 248, 67, 254, 99, 83, 238, 5, 114, 88, 215, 28, 122, 104, + 90, 4, 221, 185, 80, 21, 198, 214, 26, 137, 26, 69, 103, 235, + 92, 127, 247, 65, 118, 210, 174, 195, 110, 187, 217, 124, + 239, 81, 63, 146, 217, 249, 39, 215, 34, 20, 228, 99, 240, + 248, 32, 88, 68, 235, 16, 51, 177, 128, 209, 106, 209, 6, + 233, 250, 71, 235, 41, 46, 91, 250, 232, 187, 176, 244, 93, + 88, 104, 173, 44, 252, 174, 81, 42, 97, 217, 134, 244, 212, + 210, 226, 239, 26, 69, 108, 93, 13, 46, 134, 1, 108, 102, + 250, 138, 94, 96, 28, 23, 186, 209, 250, 232, 24, 30, 96, + 5, 87, 88, 60, 135, 71, 52, 147, 137, 209, 99, 56, 34, 87, + 215, 7, 216, 247, 201, 155, 6, 6, 173, 170, 219, 104, 165, + 152, 122, 65, 6, 223, 5, 187, 157, 62, 181, 82, 203, 37, 220, + 223, 94, 221, 94, 192, 151, 228, 41, 70, 76, 2, 97, 15, 207, + 212, 131, 99, 132, 150, 66, 106, 65, 8, 234, 156, 181, 202, + 224, 105, 135, 115, 142, 241, 91, 95, 203, 240, 127, 39, 146, + 237, 118, 254, 61, 107, 158, 120, 135, 60, 107, 53, 109, 183, + 88, 50, 165, 130, 219, 147, 164, 85, 163, 181, 186, 196, 61, + 49, 174, 157, 239, 204, 27, 240, 153, 116, 53, 177, 110, 240, + 251, 140, 107, 106, 64, 121, 74, 194, 116, 56, 32, 195, 197, + 10, 254, 59, 93, 194, 126, 238, 139, 80, 68, 254, 116, 119, + 61, 140, 239, 108, 246, 134, 250, 36, 102, 238, 57, 181, 88, + 255, 200, 232, 207, 149, 121, 23, 197, 52, 141, 221, 144, + 220, 147, 185, 196, 117, 204, 242, 108, 154, 201, 251, 79, + 11, 58, 45, 97, 5, 175, 91, 168, 195, 156, 202, 166, 209, + 106, 172, 111, 12, 3, 176, 75, 45, 130, 165, 140, 236, 36, + 80, 42, 48, 142, 90, 171, 247, 247, 189, 65, 233, 104, 7, + 47, 208, 231, 140, 236, 93, 65, 24, 71, 168, 202, 157, 147, + 238, 207, 171, 191, 145, 95, 199, 124, 192, 137, 92, 58, 156, + 73, 107, 184, 192, 158, 120, 138, 111, 92, 68, 120, 1, 239, + 34, 30, 194, 207, 169, 235, 43, 201, 196, 88, 17, 49, 237, + 42, 212, 216, 232, 95, 1, 0, 0, 255, 255, 80, 75, 7, 8, 251, + 116, 132, 17, 158, 1, 0, 0, 5, 3, 0, 0, 80, 75, 3, 4, 20, + 0, 8, 0, 8, 0, 189, 144, 140, 79, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, 9, 0, 115, 121, 110, 116, 97, 120, 47, + 103, 111, 108, 97, 110, 103, 47, 115, 112, 101, 99, 95, 115, + 117, 105, 116, 101, 46, 103, 111, 46, 116, 112, 108, 85, 84, + 5, 0, 1, 134, 129, 242, 93, 108, 205, 193, 202, 194, 48, 16, + 4, 224, 115, 246, 41, 150, 156, 146, 159, 159, 246, 45, 196, + 115, 219, 187, 196, 184, 174, 75, 219, 164, 36, 27, 47, 226, + 187, 75, 177, 71, 111, 195, 12, 124, 179, 133, 56, 7, 38, + 172, 84, 158, 18, 233, 162, 84, 21, 64, 214, 45, 23, 69, 7, + 198, 238, 133, 36, 182, 0, 166, 67, 203, 162, 143, 118, 237, + 98, 94, 251, 156, 170, 244, 44, 105, 230, 108, 127, 111, 121, + 37, 14, 22, 60, 192, 189, 165, 136, 19, 85, 29, 191, 55, 78, + 241, 239, 128, 187, 201, 227, 11, 204, 64, 44, 85, 169, 156, + 130, 44, 231, 144, 110, 11, 21, 183, 103, 15, 102, 104, 105, + 220, 40, 86, 167, 255, 104, 15, 0, 199, 38, 74, 214, 195, + 27, 62, 1, 0, 0, 255, 255, 80, 75, 7, 8, 251, 190, 56, 89, + 146, 0, 0, 0, 194, 0, 0, 0, 80, 75, 3, 4, 20, 0, 8, 0, 8, + 0, 142, 186, 134, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 27, 0, 9, 0, 115, 121, 110, 116, 97, 120, 47, 103, 111, 108, + 97, 110, 103, 47, 115, 116, 97, 116, 117, 115, 46, 103, 111, + 46, 116, 112, 108, 85, 84, 5, 0, 1, 61, 226, 234, 93, 116, + 143, 177, 78, 196, 48, 16, 68, 235, 243, 87, 140, 92, 37, + 72, 112, 125, 122, 90, 40, 224, 7, 140, 61, 7, 22, 231, 245, + 201, 222, 32, 130, 241, 191, 35, 19, 10, 40, 104, 119, 231, + 105, 222, 180, 118, 13, 159, 83, 162, 40, 236, 131, 58, 93, + 43, 10, 117, 45, 82, 225, 4, 47, 170, 23, 212, 253, 236, 115, + 160, 69, 239, 230, 15, 83, 181, 196, 192, 229, 153, 194, 226, + 148, 22, 211, 43, 55, 220, 20, 122, 198, 55, 150, 17, 24, + 180, 157, 7, 121, 90, 197, 99, 122, 199, 85, 107, 191, 34, + 159, 240, 46, 241, 28, 63, 136, 222, 103, 236, 22, 211, 140, + 40, 138, 102, 14, 199, 35, 126, 74, 2, 79, 81, 136, 167, 28, + 182, 165, 170, 43, 250, 253, 188, 187, 127, 188, 93, 32, 89, + 17, 211, 229, 204, 161, 197, 240, 31, 70, 9, 230, 176, 15, + 196, 144, 24, 163, 134, 89, 55, 95, 1, 0, 0, 255, 255, 80, + 75, 7, 8, 64, 116, 193, 223, 173, 0, 0, 0, 10, 1, 0, 0, 80, + 75, 3, 4, 20, 0, 8, 0, 8, 0, 93, 40, 140, 79, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 29, 0, 9, 0, 115, 121, 110, 116, 97, + 120, 47, 109, 97, 114, 107, 100, 111, 119, 110, 47, 114, 101, + 97, 100, 109, 101, 46, 109, 100, 46, 116, 112, 108, 85, 84, + 5, 0, 1, 2, 202, 241, 93, 148, 85, 221, 110, 27, 55, 19, 189, + 231, 83, 12, 108, 1, 95, 20, 68, 187, 240, 119, 41, 32, 64, + 227, 58, 85, 250, 99, 200, 72, 221, 139, 66, 40, 98, 106, + 57, 218, 157, 136, 203, 217, 114, 184, 187, 81, 19, 191, 123, + 65, 82, 242, 42, 128, 91, 164, 87, 162, 102, 135, 156, 115, + 206, 156, 33, 47, 225, 243, 103, 40, 2, 5, 139, 240, 248, + 168, 84, 252, 103, 80, 42, 79, 93, 32, 118, 41, 246, 230, + 238, 71, 24, 208, 11, 177, 91, 166, 244, 227, 159, 244, 241, + 242, 242, 18, 214, 3, 250, 129, 112, 84, 234, 190, 33, 1, + 65, 63, 160, 135, 81, 11, 212, 232, 208, 235, 128, 6, 182, + 7, 216, 72, 240, 100, 240, 143, 23, 77, 8, 157, 44, 203, 178, + 166, 208, 244, 219, 162, 226, 182, 236, 26, 174, 217, 234, + 173, 148, 57, 105, 14, 157, 231, 143, 88, 133, 2, 114, 141, + 59, 143, 30, 255, 236, 73, 40, 160, 82, 191, 115, 15, 210, + 112, 111, 13, 52, 122, 64, 8, 13, 194, 142, 173, 229, 145, + 92, 13, 129, 217, 10, 144, 147, 160, 173, 69, 179, 84, 106, + 1, 155, 21, 91, 237, 234, 169, 248, 56, 142, 69, 157, 98, + 5, 251, 122, 14, 113, 213, 235, 26, 225, 133, 14, 96, 81, + 75, 56, 145, 134, 171, 226, 234, 255, 115, 165, 94, 222, 234, + 61, 130, 244, 62, 214, 211, 33, 21, 69, 55, 144, 103, 215, + 162, 11, 48, 104, 79, 122, 107, 17, 30, 86, 235, 187, 55, + 247, 239, 30, 32, 137, 17, 10, 184, 111, 206, 130, 134, 60, + 86, 129, 253, 65, 141, 100, 45, 108, 17, 122, 65, 3, 90, 96, + 100, 191, 151, 78, 87, 56, 229, 192, 142, 61, 104, 107, 97, + 181, 62, 41, 34, 197, 203, 44, 201, 10, 67, 136, 116, 127, + 13, 218, 7, 52, 74, 209, 14, 14, 220, 67, 195, 146, 193, 9, + 247, 190, 66, 168, 216, 32, 176, 131, 154, 2, 104, 103, 98, + 142, 63, 29, 6, 141, 22, 208, 208, 121, 26, 116, 64, 48, 216, + 161, 51, 232, 42, 66, 81, 135, 73, 228, 138, 221, 142, 234, + 200, 60, 109, 142, 39, 85, 150, 34, 233, 192, 17, 126, 138, + 116, 158, 3, 87, 108, 11, 248, 129, 125, 150, 223, 85, 177, + 47, 94, 173, 40, 188, 235, 183, 9, 84, 197, 109, 27, 81, 36, + 9, 13, 163, 228, 213, 177, 208, 22, 151, 74, 61, 60, 60, 168, + 89, 46, 146, 234, 194, 98, 81, 91, 222, 106, 11, 189, 183, + 197, 69, 77, 225, 187, 201, 58, 203, 139, 34, 150, 66, 109, + 214, 59, 184, 120, 198, 90, 23, 233, 60, 21, 123, 112, 78, + 15, 180, 71, 104, 181, 211, 117, 118, 103, 246, 199, 255, + 68, 109, 90, 54, 189, 69, 121, 214, 167, 217, 49, 101, 205, + 229, 72, 123, 42, 111, 115, 234, 124, 58, 249, 0, 114, 144, + 128, 109, 166, 177, 213, 210, 168, 25, 224, 167, 142, 125, + 128, 213, 250, 234, 234, 234, 118, 125, 243, 219, 47, 111, + 95, 179, 155, 226, 119, 239, 215, 63, 189, 253, 254, 254, + 195, 221, 207, 171, 215, 113, 190, 78, 189, 121, 124, 84, + 51, 168, 12, 204, 178, 117, 74, 241, 85, 57, 59, 75, 142, + 34, 49, 212, 24, 160, 40, 139, 162, 200, 60, 163, 51, 222, + 247, 206, 165, 65, 104, 16, 2, 74, 144, 76, 191, 211, 213, + 94, 215, 40, 209, 151, 49, 140, 6, 200, 169, 205, 245, 205, + 205, 196, 21, 93, 17, 153, 117, 104, 72, 199, 193, 200, 60, + 175, 177, 209, 3, 177, 95, 24, 79, 3, 186, 15, 6, 7, 180, + 220, 69, 219, 207, 65, 194, 193, 98, 106, 186, 74, 173, 236, + 122, 223, 177, 224, 43, 24, 49, 137, 220, 75, 196, 178, 89, + 145, 219, 215, 156, 43, 45, 203, 146, 157, 80, 113, 84, 150, + 184, 172, 211, 215, 114, 30, 29, 170, 54, 43, 110, 177, 214, + 255, 152, 155, 190, 150, 243, 39, 66, 69, 190, 17, 42, 237, + 78, 83, 159, 102, 134, 119, 81, 129, 54, 118, 23, 63, 97, + 213, 135, 147, 38, 211, 85, 113, 116, 163, 124, 213, 174, + 163, 168, 103, 109, 143, 0, 78, 16, 243, 207, 191, 164, 37, + 116, 79, 166, 115, 105, 38, 35, 52, 223, 187, 4, 43, 117, 4, 70, 10, 205, 243, 96, 190, 198, 146, 170, 193, 194, 79, 221, 189, 238, 201, 154, 19, 149, 45, 57, 237, 15, 231, 59, 218, 189, 33, 15, 139, 14, 182, 49, 47, 227, 76, 75, 88, 48, @@ -525360,104 +525414,116 @@ func init() { 0, 0, 164, 129, 148, 190, 68, 0, 115, 121, 110, 116, 97, 120, 47, 103, 111, 108, 97, 110, 103, 47, 115, 101, 114, 118, 101, 114, 46, 103, 111, 46, 116, 112, 108, 85, 84, 5, 0, 1, 61, - 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, - 186, 134, 79, 64, 116, 193, 223, 173, 0, 0, 0, 10, 1, 0, 0, - 27, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 151, 192, 68, + 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 249, + 146, 140, 79, 251, 116, 132, 17, 158, 1, 0, 0, 5, 3, 0, 0, + 25, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 151, 192, 68, 0, 115, 121, 110, 116, 97, 120, 47, 103, 111, 108, 97, 110, - 103, 47, 115, 116, 97, 116, 117, 115, 46, 103, 111, 46, 116, - 112, 108, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, - 20, 3, 20, 0, 8, 0, 8, 0, 93, 40, 140, 79, 22, 119, 55, 77, - 143, 3, 0, 0, 124, 7, 0, 0, 29, 0, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 164, 129, 150, 193, 68, 0, 115, 121, 110, 116, 97, 120, - 47, 109, 97, 114, 107, 100, 111, 119, 110, 47, 114, 101, 97, - 100, 109, 101, 46, 109, 100, 46, 116, 112, 108, 85, 84, 5, - 0, 1, 2, 202, 241, 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, - 0, 142, 186, 134, 79, 253, 248, 68, 155, 192, 1, 0, 0, 92, - 3, 0, 0, 16, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 121, - 197, 68, 0, 118, 105, 101, 119, 101, 114, 47, 82, 69, 65, - 68, 77, 69, 46, 109, 100, 85, 84, 5, 0, 1, 61, 226, 234, 93, - 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, - 183, 77, 81, 25, 57, 1, 0, 0, 18, 2, 0, 0, 23, 0, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 164, 129, 128, 199, 68, 0, 118, 105, - 101, 119, 101, 114, 47, 97, 98, 115, 111, 108, 117, 116, 101, - 45, 112, 97, 116, 104, 46, 106, 115, 85, 84, 5, 0, 1, 61, + 103, 47, 115, 112, 101, 99, 46, 103, 111, 46, 116, 112, 108, + 85, 84, 5, 0, 1, 183, 133, 242, 93, 80, 75, 1, 2, 20, 3, 20, + 0, 8, 0, 8, 0, 189, 144, 140, 79, 251, 190, 56, 89, 146, 0, + 0, 0, 194, 0, 0, 0, 31, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, + 129, 133, 194, 68, 0, 115, 121, 110, 116, 97, 120, 47, 103, + 111, 108, 97, 110, 103, 47, 115, 112, 101, 99, 95, 115, 117, + 105, 116, 101, 46, 103, 111, 46, 116, 112, 108, 85, 84, 5, + 0, 1, 134, 129, 242, 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, + 8, 0, 142, 186, 134, 79, 64, 116, 193, 223, 173, 0, 0, 0, + 10, 1, 0, 0, 27, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, + 109, 195, 68, 0, 115, 121, 110, 116, 97, 120, 47, 103, 111, + 108, 97, 110, 103, 47, 115, 116, 97, 116, 117, 115, 46, 103, + 111, 46, 116, 112, 108, 85, 84, 5, 0, 1, 61, 226, 234, 93, + 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 93, 40, 140, 79, 22, + 119, 55, 77, 143, 3, 0, 0, 124, 7, 0, 0, 29, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 164, 129, 108, 196, 68, 0, 115, 121, 110, + 116, 97, 120, 47, 109, 97, 114, 107, 100, 111, 119, 110, 47, + 114, 101, 97, 100, 109, 101, 46, 109, 100, 46, 116, 112, 108, + 85, 84, 5, 0, 1, 2, 202, 241, 93, 80, 75, 1, 2, 20, 3, 20, + 0, 8, 0, 8, 0, 142, 186, 134, 79, 253, 248, 68, 155, 192, + 1, 0, 0, 92, 3, 0, 0, 16, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 164, 129, 79, 200, 68, 0, 118, 105, 101, 119, 101, 114, 47, + 82, 69, 65, 68, 77, 69, 46, 109, 100, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, - 186, 134, 79, 92, 161, 169, 83, 163, 2, 0, 0, 153, 2, 0, 0, - 24, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 7, 201, 68, - 0, 118, 105, 101, 119, 101, 114, 47, 102, 97, 118, 105, 99, - 111, 110, 45, 49, 54, 120, 49, 54, 46, 112, 110, 103, 85, - 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, - 8, 0, 8, 0, 142, 186, 134, 79, 160, 211, 159, 67, 126, 2, - 0, 0, 116, 2, 0, 0, 24, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, - 129, 249, 203, 68, 0, 118, 105, 101, 119, 101, 114, 47, 102, - 97, 118, 105, 99, 111, 110, 45, 51, 50, 120, 51, 50, 46, 112, - 110, 103, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, - 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, 46, 4, 164, 65, - 138, 2, 0, 0, 3, 6, 0, 0, 17, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 164, 129, 198, 206, 68, 0, 118, 105, 101, 119, 101, 114, - 47, 105, 110, 100, 101, 120, 46, 104, 116, 109, 108, 85, 84, - 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, - 0, 8, 0, 142, 186, 134, 79, 204, 45, 113, 68, 164, 1, 0, 0, - 45, 3, 0, 0, 15, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, - 152, 209, 68, 0, 118, 105, 101, 119, 101, 114, 47, 105, 110, - 100, 101, 120, 46, 106, 115, 85, 84, 5, 0, 1, 61, 226, 234, + 186, 134, 79, 183, 77, 81, 25, 57, 1, 0, 0, 18, 2, 0, 0, 23, + 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 86, 202, 68, 0, + 118, 105, 101, 119, 101, 114, 47, 97, 98, 115, 111, 108, 117, + 116, 101, 45, 112, 97, 116, 104, 46, 106, 115, 85, 84, 5, + 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, + 8, 0, 142, 186, 134, 79, 92, 161, 169, 83, 163, 2, 0, 0, 153, + 2, 0, 0, 24, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 221, + 203, 68, 0, 118, 105, 101, 119, 101, 114, 47, 102, 97, 118, + 105, 99, 111, 110, 45, 49, 54, 120, 49, 54, 46, 112, 110, + 103, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, + 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, 160, 211, 159, 67, + 126, 2, 0, 0, 116, 2, 0, 0, 24, 0, 9, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 164, 129, 207, 206, 68, 0, 118, 105, 101, 119, 101, + 114, 47, 102, 97, 118, 105, 99, 111, 110, 45, 51, 50, 120, + 51, 50, 46, 112, 110, 103, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, - 79, 93, 18, 114, 9, 57, 3, 0, 0, 84, 9, 0, 0, 27, 0, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 130, 211, 68, 0, 118, 105, - 101, 119, 101, 114, 47, 111, 97, 117, 116, 104, 50, 45, 114, - 101, 100, 105, 114, 101, 99, 116, 46, 104, 116, 109, 108, - 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, - 0, 8, 0, 8, 0, 142, 186, 134, 79, 119, 77, 176, 246, 23, 3, - 0, 0, 129, 7, 0, 0, 19, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, - 129, 13, 215, 68, 0, 118, 105, 101, 119, 101, 114, 47, 112, - 97, 99, 107, 97, 103, 101, 46, 106, 115, 111, 110, 85, 84, + 79, 46, 4, 164, 65, 138, 2, 0, 0, 3, 6, 0, 0, 17, 0, 9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 156, 209, 68, 0, 118, 105, + 101, 119, 101, 114, 47, 105, 110, 100, 101, 120, 46, 104, + 116, 109, 108, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, + 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, 204, 45, + 113, 68, 164, 1, 0, 0, 45, 3, 0, 0, 15, 0, 9, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 164, 129, 110, 212, 68, 0, 118, 105, 101, 119, + 101, 114, 47, 105, 110, 100, 101, 120, 46, 106, 115, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, - 0, 8, 0, 142, 186, 134, 79, 50, 228, 202, 9, 126, 70, 4, 0, - 241, 104, 14, 0, 27, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, - 129, 110, 218, 68, 0, 118, 105, 101, 119, 101, 114, 47, 115, - 119, 97, 103, 103, 101, 114, 45, 117, 105, 45, 98, 117, 110, - 100, 108, 101, 46, 106, 115, 85, 84, 5, 0, 1, 61, 226, 234, - 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, - 79, 172, 118, 142, 227, 119, 189, 15, 0, 123, 205, 60, 0, - 31, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 62, 33, 73, - 0, 118, 105, 101, 119, 101, 114, 47, 115, 119, 97, 103, 103, - 101, 114, 45, 117, 105, 45, 98, 117, 110, 100, 108, 101, 46, - 106, 115, 46, 109, 97, 112, 85, 84, 5, 0, 1, 61, 226, 234, - 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, - 79, 230, 188, 130, 126, 164, 145, 1, 0, 198, 254, 4, 0, 38, - 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 11, 223, 88, 0, - 118, 105, 101, 119, 101, 114, 47, 115, 119, 97, 103, 103, - 101, 114, 45, 117, 105, 45, 115, 116, 97, 110, 100, 97, 108, - 111, 110, 101, 45, 112, 114, 101, 115, 101, 116, 46, 106, - 115, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, - 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, 94, 253, 29, 219, - 39, 168, 5, 0, 68, 73, 22, 0, 42, 0, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 164, 129, 12, 113, 90, 0, 118, 105, 101, 119, 101, - 114, 47, 115, 119, 97, 103, 103, 101, 114, 45, 117, 105, 45, - 115, 116, 97, 110, 100, 97, 108, 111, 110, 101, 45, 112, 114, - 101, 115, 101, 116, 46, 106, 115, 46, 109, 97, 112, 85, 84, + 0, 8, 0, 142, 186, 134, 79, 93, 18, 114, 9, 57, 3, 0, 0, 84, + 9, 0, 0, 27, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 88, + 214, 68, 0, 118, 105, 101, 119, 101, 114, 47, 111, 97, 117, + 116, 104, 50, 45, 114, 101, 100, 105, 114, 101, 99, 116, 46, + 104, 116, 109, 108, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, + 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, 119, + 77, 176, 246, 23, 3, 0, 0, 129, 7, 0, 0, 19, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 164, 129, 227, 217, 68, 0, 118, 105, 101, + 119, 101, 114, 47, 112, 97, 99, 107, 97, 103, 101, 46, 106, + 115, 111, 110, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, + 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, 50, 228, + 202, 9, 126, 70, 4, 0, 241, 104, 14, 0, 27, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 164, 129, 68, 221, 68, 0, 118, 105, 101, + 119, 101, 114, 47, 115, 119, 97, 103, 103, 101, 114, 45, 117, + 105, 45, 98, 117, 110, 100, 108, 101, 46, 106, 115, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, - 0, 8, 0, 142, 186, 134, 79, 4, 138, 252, 135, 18, 90, 0, 0, - 150, 89, 2, 0, 21, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, - 148, 25, 96, 0, 118, 105, 101, 119, 101, 114, 47, 115, 119, - 97, 103, 103, 101, 114, 45, 117, 105, 46, 99, 115, 115, 85, + 0, 8, 0, 142, 186, 134, 79, 172, 118, 142, 227, 119, 189, + 15, 0, 123, 205, 60, 0, 31, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 164, 129, 20, 36, 73, 0, 118, 105, 101, 119, 101, 114, + 47, 115, 119, 97, 103, 103, 101, 114, 45, 117, 105, 45, 98, + 117, 110, 100, 108, 101, 46, 106, 115, 46, 109, 97, 112, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, - 8, 0, 8, 0, 142, 186, 134, 79, 61, 95, 139, 209, 83, 0, 0, - 0, 91, 0, 0, 0, 25, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, - 129, 242, 115, 96, 0, 118, 105, 101, 119, 101, 114, 47, 115, - 119, 97, 103, 103, 101, 114, 45, 117, 105, 46, 99, 115, 115, + 8, 0, 8, 0, 142, 186, 134, 79, 230, 188, 130, 126, 164, 145, + 1, 0, 198, 254, 4, 0, 38, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 164, 129, 225, 225, 88, 0, 118, 105, 101, 119, 101, 114, 47, + 115, 119, 97, 103, 103, 101, 114, 45, 117, 105, 45, 115, 116, + 97, 110, 100, 97, 108, 111, 110, 101, 45, 112, 114, 101, 115, + 101, 116, 46, 106, 115, 85, 84, 5, 0, 1, 61, 226, 234, 93, + 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, + 94, 253, 29, 219, 39, 168, 5, 0, 68, 73, 22, 0, 42, 0, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 226, 115, 90, 0, 118, + 105, 101, 119, 101, 114, 47, 115, 119, 97, 103, 103, 101, + 114, 45, 117, 105, 45, 115, 116, 97, 110, 100, 97, 108, 111, + 110, 101, 45, 112, 114, 101, 115, 101, 116, 46, 106, 115, 46, 109, 97, 112, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, - 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, 44, 237, - 96, 224, 212, 95, 2, 0, 160, 208, 11, 0, 20, 0, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 164, 129, 149, 116, 96, 0, 118, 105, 101, + 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, 4, 138, + 252, 135, 18, 90, 0, 0, 150, 89, 2, 0, 21, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 164, 129, 106, 28, 96, 0, 118, 105, 101, 119, 101, 114, 47, 115, 119, 97, 103, 103, 101, 114, 45, 117, - 105, 46, 106, 115, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, - 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, 7, - 115, 59, 104, 176, 240, 5, 0, 167, 65, 23, 0, 24, 0, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 164, 129, 180, 212, 98, 0, 118, 105, + 105, 46, 99, 115, 115, 85, 84, 5, 0, 1, 61, 226, 234, 93, + 80, 75, 1, 2, 20, 3, 20, 0, 8, 0, 8, 0, 142, 186, 134, 79, + 61, 95, 139, 209, 83, 0, 0, 0, 91, 0, 0, 0, 25, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 164, 129, 200, 118, 96, 0, 118, 105, 101, 119, 101, 114, 47, 115, 119, 97, 103, 103, 101, 114, - 45, 117, 105, 46, 106, 115, 46, 109, 97, 112, 85, 84, 5, 0, - 1, 61, 226, 234, 93, 80, 75, 5, 6, 0, 0, 0, 0, 39, 0, 39, - 0, 102, 12, 0, 0, 179, 197, 104, 0, 0, 0, + 45, 117, 105, 46, 99, 115, 115, 46, 109, 97, 112, 85, 84, + 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, 8, + 0, 8, 0, 142, 186, 134, 79, 44, 237, 96, 224, 212, 95, 2, + 0, 160, 208, 11, 0, 20, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164, + 129, 107, 119, 96, 0, 118, 105, 101, 119, 101, 114, 47, 115, + 119, 97, 103, 103, 101, 114, 45, 117, 105, 46, 106, 115, 85, + 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, 1, 2, 20, 3, 20, 0, + 8, 0, 8, 0, 142, 186, 134, 79, 7, 115, 59, 104, 176, 240, + 5, 0, 167, 65, 23, 0, 24, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 164, 129, 138, 215, 98, 0, 118, 105, 101, 119, 101, 114, 47, + 115, 119, 97, 103, 103, 101, 114, 45, 117, 105, 46, 106, 115, + 46, 109, 97, 112, 85, 84, 5, 0, 1, 61, 226, 234, 93, 80, 75, + 5, 6, 0, 0, 0, 0, 41, 0, 41, 0, 12, 13, 0, 0, 137, 200, 104, + 0, 0, 0, }) } diff --git a/template/syntax/golang/spec.go.tpl b/template/syntax/golang/spec.go.tpl new file mode 100644 index 0000000..ece194f --- /dev/null +++ b/template/syntax/golang/spec.go.tpl @@ -0,0 +1,38 @@ +package service_test + +import ( + "github.com/go-chi/chi" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "{{ .project }}" +) + +var _ = Describe("{{ .receiver }}", func() { + var ( + router chi.Router + // TODO: Uncomment if you are going to test your code + // request *http.Request + // recorder *httptest.ResponseRecorder + ) + + BeforeEach(func() { + router = chi.NewRouter() + + controller := &service.CustomerAPI{} + controller.Mount(router) + + Expect(router.Routes()).NotTo(BeEmpty()) + + // TODO: Uncomment if you are going to test your code + // recorder = httptest.NewRecorder() + }) + + {{ range .operations }} + + Describe("{{ .Method | uppercase }} {{ .Path }}", func() { + // TODO: Implement the test cases for {{ .Name | camelize }} operation + }) + {{ end }} +}) diff --git a/template/syntax/golang/spec_suite.go.tpl b/template/syntax/golang/spec_suite.go.tpl new file mode 100644 index 0000000..2a364da --- /dev/null +++ b/template/syntax/golang/spec_suite.go.tpl @@ -0,0 +1,13 @@ +package service_test + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +func TestService(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Service Suite") +}