Skip to content

Commit

Permalink
fix: use updated cli-skeleton to ensure output is not padded to 80 ch…
Browse files Browse the repository at this point in the history
…aracters with invisible whitespace

Also add tests to ensure this is the case for list output.
  • Loading branch information
josegonzalez committed Feb 11, 2024
1 parent 0642f05 commit 325e7a3
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 26 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2
github.com/joho/godotenv v1.5.1
github.com/josegonzalez/cli-skeleton v0.15.0
github.com/josegonzalez/cli-skeleton v0.16.0
github.com/mitchellh/cli v1.1.5
github.com/posener/complete v1.2.3
github.com/spf13/pflag v1.0.5
Expand Down Expand Up @@ -33,7 +33,7 @@ require (
github.com/rs/zerolog v1.32.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
)
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/josegonzalez/cli-skeleton v0.15.0 h1:8AuxPC+KioDnBf9K+ZIE+1tYbayOUBJAluoUnCyHdIc=
github.com/josegonzalez/cli-skeleton v0.15.0/go.mod h1:iCpaNFH5JS8kk8VfEsa+Ml6VNw/3oIIPYV7XDXaBypA=
github.com/josegonzalez/cli-skeleton v0.16.0 h1:IKt/d42bCswjL4KfYMTMZPZHcBgKzc4etawi/8hYk2o=
github.com/josegonzalez/cli-skeleton v0.16.0/go.mod h1:Ct2h/SppcOOPkarLPk6LNmMSCDzCQRv9bpNv1oeRXZI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
Expand Down Expand Up @@ -93,8 +93,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -104,10 +104,10 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61 h1:8ajkpB4hXVftY5ko905id+dOnmorcS2CHNxxHLLDcFM=
gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61/go.mod h1:IfMagxm39Ys4ybJrDb7W3Ob8RwxftP0Yy+or/NVz1O8=
Expand Down
98 changes: 84 additions & 14 deletions test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,87 +16,157 @@ teardown_file() {
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "valid procfile detected 2custom, cron, custom, release, web, wor-ker"
assert_output "valid procfile detected 2custom, cron, custom, release, web, wor-ker"

run $PROCFILE_BIN list -P fixtures/comments.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output "2custom
cron
custom
release
web
wor-ker"
}

@test "[lax] forwardslash-comments" {
run $PROCFILE_BIN check -P fixtures/forwardslash-comments.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "valid procfile detected web, worker, worker-2"
assert_output "valid procfile detected web, worker, worker-2"

run $PROCFILE_BIN show -P fixtures/forwardslash-comments.Procfile -p worker
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "node worker.js"
assert_output "node worker.js"

run $PROCFILE_BIN list -P fixtures/forwardslash-comments.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output "web
worker
worker-2"
}

@test "[lax] multiple" {
run $PROCFILE_BIN check -P fixtures/multiple.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "valid procfile detected release, web, webpacker, worker"
assert_output "valid procfile detected release, web, webpacker, worker"

run $PROCFILE_BIN list -P fixtures/multiple.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output "release
web
webpacker
worker"
}

@test "[lax] port" {
run $PROCFILE_BIN check -P fixtures/port.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "valid procfile detected web, worker"
assert_output "valid procfile detected web, worker"

run $PROCFILE_BIN show -P fixtures/port.Procfile -p web
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "node web.js --port 5000"
assert_output "node web.js --port 5000"

run $PROCFILE_BIN list -P fixtures/port.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output "web
worker"
}

@test "[strict] comments" {
run $PROCFILE_BIN check -S -P fixtures/comments.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "valid procfile detected 2custom, cron, custom, release, web, wor-ker"
assert_output "valid procfile detected 2custom, cron, custom, release, web, wor-ker"

run $PROCFILE_BIN list -S -P fixtures/comments.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output "2custom
cron
custom
release
web
wor-ker"
}

@test "[strict] forwardslash-comments" {
run $PROCFILE_BIN check -S -P fixtures/forwardslash-comments.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "valid procfile detected web, worker, worker-2"
assert_output "valid procfile detected web, worker, worker-2"

run $PROCFILE_BIN show -S -P fixtures/forwardslash-comments.Procfile -p worker
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "node worker.js"
assert_output "node worker.js"

run $PROCFILE_BIN list -S -P fixtures/forwardslash-comments.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output "web
worker
worker-2"
}

@test "[strict] multiple" {
run $PROCFILE_BIN check -S -P fixtures/multiple.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "valid procfile detected release, web, webpacker, worker"
assert_output "valid procfile detected release, web, webpacker, worker"

run $PROCFILE_BIN list -S -P fixtures/multiple.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output "release
web
webpacker
worker"
}

@test "[strict] port" {
run $PROCFILE_BIN check -S -P fixtures/port.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "valid procfile detected web, worker"
assert_output "valid procfile detected web, worker"

run $PROCFILE_BIN show -S -P fixtures/port.Procfile -p web
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output_contains "node web.js --port 5000"
assert_output "node web.js --port 5000"

run $PROCFILE_BIN list -S -P fixtures/port.Procfile
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output "web
worker"
}

flunk() {
Expand All @@ -113,8 +183,8 @@ flunk() {
assert_equal() {
if [[ "$1" != "$2" ]]; then
{
echo "expected: $1"
echo "actual: $2"
echo "expected: '$1'"
echo "actual: '$2'"
} | flunk
fi
}
Expand Down

0 comments on commit 325e7a3

Please sign in to comment.