steinfletcher / apitest

A simple and extensible behavioural testing library for Go. You can use api test to simplify REST API, HTTP handler and e2e tests.
https://apitest.dev
MIT License
795 stars 55 forks source link

Output sequence diagram with custom name instead of hash #140

Closed nao1215 closed 1 year ago

nao1215 commented 1 year ago

Is your feature request related to a problem? Please describe. This issue is same as #116 .

The apitest package generates sequence diagrams (it's great feature. I was impressed.). This diagram has a hash as the file name. I want to store sequence diagrams in a document directory to share them with developers. However, using hash names for file titles is a bit inconvenient.

So, I wanted to give custom names to the sequence diagrams.

Describe the solution you'd like The solution is to add CustomeSequenceDiagramName(). (Method name may not be appropriate)

example

                Report(apitest.SequenceDiagram()).
                CustomeSequenceDiagramName("diagram_name_is_here").
                // ...
                End()

CustomSequenceDiagramName set APITest.meta["diagramName"]. If meta['diagramName'] is set, the hash name will not be used when outputting the sequence diagram. The problem with this approach is that if you execute Meta() after executing CustomSequenceDiagramName(), the settings from CustomSequenceDiagramName() are lost.

Describe alternatives you've considered The alternative way is implementing new ReportFormatter interface. This method has a large modification scale. However, it has the advantage of being able to be implemented outside of the apitest package (I would adopt this idea if no additional features were added).

Additional context I find the apitest package useful. I can implement it if you decide on a policy.

nao1215 commented 1 year ago

I decided to fork apitest and proceed with the development. Sorry to be so one-sided, but I am closing this.