Skip to content

Commit

Permalink
resolves #15 support unrecognized type (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie authored Jul 2, 2022
1 parent 3a38bc8 commit 9f246e5
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 18 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ name: CI

on:
push:
branches: master
branches: [master]
pull_request:
branches: master
branches: [master]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go ^1.11
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: ^1.11
go-version: 1.18
- uses: actions/checkout@v2
- name: Installer linter (golangci)
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v${GOLANGCI_LINT_VERSION}
env:
GOLANGCI_LINT_VERSION: '1.33.0'
GOLANGCI_LINT_VERSION: '1.46.2'
- name: Get dependencies
run: go mod vendor
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- name: Set up Go ^1.11
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: ^1.11
go-version: 1.18
- uses: actions/checkout@v2
- name: Installer linter (golangci)
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v${GOLANGCI_LINT_VERSION}
env:
GOLANGCI_LINT_VERSION: '1.33.0'
GOLANGCI_LINT_VERSION: '1.46.2'
- name: Get dependencies
run: go mod vendor
env:
Expand Down
5 changes: 2 additions & 3 deletions cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ func GraphFormatFromValue(value string) (kroki.DiagramType, error) {
if d, ok := getDiagramTypeNames()[value]; ok {
return d, nil
}
return "", errors.Errorf(
"invalid graph format %s.",
value)
// support unrecognized type
return kroki.DiagramType(value), nil
}

func GraphFormatFromFile(filePath string) (kroki.DiagramType, error) {
Expand Down
26 changes: 26 additions & 0 deletions cmd/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,32 @@ func TestResolveImageFormat(t *testing.T) {
}
}

func TestGraphFormatFromValue(t *testing.T) {
cases := []struct {
diagramTypeRaw string
expected kroki.DiagramType
}{
{
diagramTypeRaw: "VegaLite",
expected: kroki.VegaLite,
},
{
diagramTypeRaw: "diagramsnet",
expected: kroki.DiagramType("diagramsnet"),
},
{
diagramTypeRaw: "Structurizr",
expected: kroki.DiagramType("structurizr"),
},
}
for _, c := range cases {
result, _ := GraphFormatFromValue(c.diagramTypeRaw)
if result != c.expected {
t.Errorf("GraphFormatFromValue error\nexpected: %s\nactual: %s", c.expected, result)
}
}
}

func TestConvertFromReader(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
expected := "eNpKyUwvSizIUHBXqPZIzcnJ17ULzy_KSakFBAAA__9sQAjG"
Expand Down
21 changes: 18 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
module kroki

go 1.14
go 1.18

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/pkg/errors v0.8.1
github.com/spf13/cobra v0.0.3
github.com/spf13/viper v1.3.1
github.com/yuzutech/kroki-go v0.6.2
)

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/magiconair/properties v1.8.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a // indirect
golang.org/x/text v0.3.0 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
)
9 changes: 5 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand All @@ -18,6 +20,7 @@ github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
Expand All @@ -31,20 +34,18 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38=
github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuzutech/kroki-go v0.6.0 h1:0BNsiwS/xFupdXzaz4MTMzyfYuqoK/RXiFff1YMkWM4=
github.com/yuzutech/kroki-go v0.6.0/go.mod h1:Cys0gjXdlViePdrZ4AKMUyX4yVIAoIhMBhvpYPJahrk=
github.com/yuzutech/kroki-go v0.6.1 h1:ruEUFpglD2B901cRPajOm8XfaMR+lAcvgayx2tn3G8w=
github.com/yuzutech/kroki-go v0.6.1/go.mod h1:gtJV1+Z2gBmJlCTjAeIZZY9J4zo1AVBsWQCn1WeCD9c=
github.com/yuzutech/kroki-go v0.6.2 h1:+VHC0PQdtG68A8v/9oK85slzovhHFiLkJ2H/3CRwLBw=
github.com/yuzutech/kroki-go v0.6.2/go.mod h1:gtJV1+Z2gBmJlCTjAeIZZY9J4zo1AVBsWQCn1WeCD9c=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a h1:1n5lsVfiQW3yfsRGu98756EH1YthsFqr/5mxHduZW2A=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 comments on commit 9f246e5

Please sign in to comment.