// +build go1.8,codegen package api import ( "testing" ) func TestDocstring(t *testing.T) { cases := map[string]struct { In string Expect string }{ "non HTML": { In: "Testing 1 2 3", Expect: "// Testing 1 2 3", }, "link": { In: `a link`, Expect: "// a link (https://example.com)", }, "link with space": { In: `a link`, Expect: "// a link (https://example.com)", }, "list HTML 01": { In: "
Testing 1 2 3
FooBar
Testing
: 1 2 3FOO
Bar
Xyz
ABC
Testing
: 1 2 3
Testing
",
Expect: "// Testing",
},
"paragraph": {
In: "Testing 1 2 3
", Expect: "// Testing 1 2 3", }, "wrap lines": { In: "CreateSecret SecretListEntry SecretName KmsKeyId", Expect: "// CreateSecret SecretListEntry SecretName KmsKeyId", }, "links with spaces": { In: "Deletes the replication configuration from the bucket. For information about replication configuration, see Cross-Region Replication (CRR) in the Amazon S3 Developer Guide.
", Expect: "// Deletes the replication configuration from the bucket. For information about\n// replication configuration, see Cross-Region Replication (CRR) (https://docs.aws.amazon.com/AmazonS3/latest/dev/crr.html)\n// in the Amazon S3 Developer Guide.", }, } for name, c := range cases { t.Run(name, func(t *testing.T) { t.Log("Input", c.In) actual := docstring(c.In) if e, a := c.Expect, actual; e != a { t.Errorf("expect %q, got %q", e, a) } }) } }