Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Add CHANGELOG file and test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasepe committed Jun 13, 2020
1 parent 98bf924 commit f651f89
Show file tree
Hide file tree
Showing 37 changed files with 867 additions and 133 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).



## [0.4.0] - 2020-06-11
### Added
- This CHANGELOG file
- Test cases
- New commandline flag `-bottom-top` to set bottom top layout
- New component kind: [`container-service`](./examples/cos.yml)
- New component kind: [`waf`](./examples/waf.yml)
- New example [./examples/system-view.yml](./examples/system-view.yml)
60 changes: 6 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,66 +134,18 @@ type Connection struct {
}
```

## Example 1 - Message Bus Pattern

The `draft` architecture descriptor YAML file is here 👉 [./examples/message-bus-pattern.yml](./examples/message-bus-pattern.yml)

Running `draft` with this command:

```bash
draft message-bus-pattern.yml | dot -Tpng > message-bus-pattern.png
```

Will generate this output:

![](./examples/message-bus-pattern.png)


## Example 2 - AWS Cognito Custom Authentication Flow

The `draft` architecture descriptor YAML file is here 👉 [./examples/aws-cognito-custom-auth-flow.yml](./examples/aws-cognito-custom-auth-flow.yml)

Running `draft` with this command:

```bash
draft aws-cognito-custom-auth-flow.yml | dot -Tpng > aws-cognito-custom-auth-flow.png
```

Will generate this output:

![](./examples/aws-cognito-custom-auth-flow.png)

## Example 3 - Getting the pre-signed URL to Upload a file to Amazon S3


The `draft` architecture descriptor YAML file is here 👉 [./examples/s3-upload-presigned-url.yml](./examples/s3-upload-presigned-url.yml)

Running `draft` with this command:

```bash
draft s3-upload-presigned-url.yml | dot -Tpng > s3-upload-presigned-url.png
```

![](./examples/s3-upload-presigned-url.png)

## Example 4 - A system view
---

The `draft` architecture descriptor YAML file is here 👉 [./examples/system-view.yml](./examples/system-view.yml)
## Changelog

Running `draft` with this command:

```bash
draft system-view.yml | dot -Tpng > system-view.png
```

![](./examples/system-view.png)
👉 [Record of all notable changes made to a project](./CHANGELOG.md)

---

## Others examples
## Examples

Check out the 👉 [./examples/](/examples/) folders for more `draft` architecture descriptor YAML examples.
👉 [Collection of draft architecture descriptor YAML files](./examples/README.md)


---

(c) 2020 Luca Sepe http://lucasepe.it. MIT License
6 changes: 3 additions & 3 deletions balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ func (rcv *balancer) nextID() string {
return fmt.Sprintf("lb%d", rcv.seq)
}

func (rcv *balancer) sketch(graph *dot.Graph, comp Component, bottomTop bool) {
func (rcv *balancer) sketch(graph *dot.Graph, comp Component) {
id := comp.ID
if strings.TrimSpace(comp.ID) == "" {
id = rcv.nextID()
}

cl := cluster.New(graph, id, cluster.BottomTop(bottomTop), cluster.Label(comp.Impl))
cl := cluster.New(graph, id, cluster.BottomTop(comp.BottomTop()), cluster.Label(comp.Impl))

el := node.New(cl, id,
node.Label("LB", false),
node.Rounded(comp.Rounded),
node.FontColor(comp.FontColor),
node.FontColor(comp.FontColor, "#000000ff"),
node.FillColor(comp.FillColor, "#1a5276ff"),
node.Shape("Mdiamond"),
)
Expand Down
40 changes: 40 additions & 0 deletions balancer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package draft

import (
"testing"

"github.com/emicklei/dot"
)

func TestLoadBalancerComponentNextID(t *testing.T) {
tests := []struct {
want string
}{
{"lb1"},
{"lb2"},
{"lb3"},
{"lb4"},
}

s := balancer{}

for _, tt := range tests {
t.Run(tt.want, func(t *testing.T) {
if got := s.nextID(); got != tt.want {
t.Errorf("got [%v] want [%v]", got, tt.want)
}
})
}
}

func TestLoadBalancerComponent(t *testing.T) {
want := `label="LB",shape="Mdiamond",style="filled"`
g := dot.NewGraph(dot.Directed)

sketcher := balancer{}
sketcher.sketch(g, Component{})

if got := flatten(g.String()); !verify(got, want) {
t.Errorf("got [%v] want [%v]", got, want)
}
}
6 changes: 3 additions & 3 deletions broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ func (rcv *broker) nextID() string {
return fmt.Sprintf("br%d", rcv.seq)
}

func (rcv *broker) sketch(graph *dot.Graph, comp Component, bottomTop bool) {
func (rcv *broker) sketch(graph *dot.Graph, comp Component) {
id := comp.ID
if strings.TrimSpace(comp.ID) == "" {
id = rcv.nextID()
}

cl := cluster.New(graph, id, cluster.BottomTop(bottomTop), cluster.Label(comp.Impl))
cl := cluster.New(graph, id, cluster.BottomTop(comp.BottomTop()), cluster.Label(comp.Impl))

el := node.New(cl, id,
node.Label("Message Broker", false),
node.Rounded(comp.Rounded),
node.FontSize(7),
node.FontColor(comp.FontColor),
node.FontColor(comp.FontColor, "#000000ff"),
node.FillColor(comp.FillColor, "#e0eeeeff"),
node.Shape("cds"),
)
Expand Down
40 changes: 40 additions & 0 deletions broker_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package draft

import (
"testing"

"github.com/emicklei/dot"
)

func TestBrokerComponentNextID(t *testing.T) {
tests := []struct {
want string
}{
{"br1"},
{"br2"},
{"br3"},
{"br4"},
}

s := broker{}

for _, tt := range tests {
t.Run(tt.want, func(t *testing.T) {
if got := s.nextID(); got != tt.want {
t.Errorf("got [%v] want [%v]", got, tt.want)
}
})
}
}

func TestBrokerComponent(t *testing.T) {
want := `label="Message Broker",shape="cds",style="filled"`
g := dot.NewGraph(dot.Directed)

sketcher := broker{}
sketcher.sketch(g, Component{})

if got := flatten(g.String()); !verify(got, want) {
t.Errorf("got [%v] want [%v]", got, want)
}
}
6 changes: 3 additions & 3 deletions cdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ func (rcv *cdn) nextID() string {
return fmt.Sprintf("cn%d", rcv.seq)
}

func (rcv *cdn) sketch(graph *dot.Graph, comp Component, bottomTop bool) {
func (rcv *cdn) sketch(graph *dot.Graph, comp Component) {
id := comp.ID
if strings.TrimSpace(comp.ID) == "" {
id = rcv.nextID()
}

cl := cluster.New(graph, id, cluster.BottomTop(bottomTop), cluster.Label(comp.Impl))
cl := cluster.New(graph, id, cluster.BottomTop(comp.BottomTop()), cluster.Label(comp.Impl))

el := node.New(cl, id,
node.Label("CDN", false),
node.FontColor(comp.FontColor),
node.FontColor(comp.FontColor, "#000000ff"),
node.FillColor(comp.FillColor, "#47df9aff"),
node.Shape("Mcircle"),
)
Expand Down
40 changes: 40 additions & 0 deletions cdn_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package draft

import (
"testing"

"github.com/emicklei/dot"
)

func TestCDNComponentNextID(t *testing.T) {
tests := []struct {
want string
}{
{"cn1"},
{"cn2"},
{"cn3"},
{"cn4"},
}

s := cdn{}

for _, tt := range tests {
t.Run(tt.want, func(t *testing.T) {
if got := s.nextID(); got != tt.want {
t.Errorf("got [%v] want [%v]", got, tt.want)
}
})
}
}

func TestCDNComponent(t *testing.T) {
want := `label="CDN",shape="Mcircle",style="filled"`
g := dot.NewGraph(dot.Directed)

sketcher := cdn{}
sketcher.sketch(g, Component{})

if got := flatten(g.String()); !verify(got, want) {
t.Errorf("got [%v] want [%v]", got, want)
}
}
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ func (rcv *client) nextID() string {
return fmt.Sprintf("cl%d", rcv.seq)
}

func (rcv *client) sketch(graph *dot.Graph, comp Component, bottomTop bool) {
func (rcv *client) sketch(graph *dot.Graph, comp Component) {
id := comp.ID
if strings.TrimSpace(comp.ID) == "" {
id = rcv.nextID()
}

cl := cluster.New(graph, id, cluster.BottomTop(bottomTop), cluster.Label(comp.Impl))
cl := cluster.New(graph, id, cluster.BottomTop(comp.BottomTop()), cluster.Label(comp.Impl))

el := node.New(cl, id,
node.Label(comp.Label, false),
node.Rounded(comp.Rounded),
node.FontColor(comp.FontColor),
node.FontColor(comp.FontColor, "#000000ff"),
node.FillColor(comp.FillColor, "#90ee90ff"),
node.Shape("underline"),
)
Expand Down
40 changes: 40 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package draft

import (
"testing"

"github.com/emicklei/dot"
)

func TestClientComponentNextID(t *testing.T) {
tests := []struct {
want string
}{
{"cl1"},
{"cl2"},
{"cl3"},
{"cl4"},
}

s := client{}

for _, tt := range tests {
t.Run(tt.want, func(t *testing.T) {
if got := s.nextID(); got != tt.want {
t.Errorf("got [%v] want [%v]", got, tt.want)
}
})
}
}

func TestClientComponent(t *testing.T) {
want := `shape="underline",style="filled"`
g := dot.NewGraph(dot.Directed)

sketcher := client{}
sketcher.sketch(g, Component{})

if got := flatten(g.String()); !verify(got, want) {
t.Errorf("got [%v] want [%v]", got, want)
}
}
11 changes: 3 additions & 8 deletions container_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,17 @@ func (rcv *containerService) nextID() string {
return fmt.Sprintf("cos%d", rcv.seq)
}

func (rcv *containerService) sketch(graph *dot.Graph, comp Component, bottomTop bool) {
func (rcv *containerService) sketch(graph *dot.Graph, comp Component) {
id := comp.ID
if strings.TrimSpace(comp.ID) == "" {
id = rcv.nextID()
}

fontColor := "#fafafaff"
if strings.TrimSpace(comp.FontColor) != "" {
fontColor = comp.FontColor
}

cl := cluster.New(graph, id, cluster.BottomTop(bottomTop), cluster.Label(comp.Impl))
cl := cluster.New(graph, id, cluster.BottomTop(comp.BottomTop()), cluster.Label(comp.Impl))

el := node.New(cl, id,
node.Label("Container\nService", false),
node.FontColor(fontColor),
node.FontColor(comp.FontColor, "#fafafaff"),
node.FillColor(comp.FillColor, "#64a365"),
node.Shape("component"),
)
Expand Down
Loading

0 comments on commit f651f89

Please sign in to comment.