Skip to content

Commit

Permalink
Merge pull request #3 from kobayashi/fix-test
Browse files Browse the repository at this point in the history
fixed tests
  • Loading branch information
kobayashi authored Jul 31, 2024
2 parents 1d2794f + 6d279c1 commit 17c0ba7
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 807 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.x
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ jobs:
os:
- ubuntu-latest
- macOS-latest
timeout-minutes: 5
steps:
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.x
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Lint
run: |
GO111MODULE=off GOBIN=$(pwd)/bin go get golang.org/x/lint/golint
bin/golint -set_exit_status ./...
if: "matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'"
uses: golangci/golangci-lint-action@v3
with:
args: --verbose
- name: Test
run: go test -v ./...
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
2 changes: 0 additions & 2 deletions cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"github.com/spf13/cobra"
)

var format string

// projectCmd represents the project command
var projectCmd = &cobra.Command{
Use: "project",
Expand Down
20 changes: 12 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ module github.com/kobayashi/eol
go 1.17

require (
github.com/fatih/color v1.13.0
github.com/jedib0t/go-pretty/v6 v6.2.4
github.com/spf13/cobra v1.3.0
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/fatih/color v1.17.0
github.com/jedib0t/go-pretty/v6 v6.5.9
github.com/spf13/cobra v1.8.1
)

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect
golang.org/x/sys v0.22.0 // indirect
)
797 changes: 39 additions & 758 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type Cycle struct {
Link *string `json:"link,omitempty"`
LTS *bool `json:"lts,omitempty"`
Support StringOrBool `json:"support,omitempty"`
CycleShortHand StringOrInt `json:"codename"`
Codename StringOrInt `json:"codename"`
Discontinued StringOrBool `json:"disconitinued"`
}

Expand Down
31 changes: 10 additions & 21 deletions pkg/commands/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package commands
import (
"context"
"errors"
"fmt"
"os"
"time"

Expand Down Expand Up @@ -108,20 +107,20 @@ func createContentList(cycles api.CycleList) (*tableContenet, error) {
}
row = append(row, *p.Cycle.I)
}
if p.CycleShortHand.S != nil {
if p.Codename.S != nil {
h := "Codename"
exist := header.isHeaderExist(h)
if !exist {
header.Row = append(header.Row, h)
}
row = append(row, *p.CycleShortHand.S)
} else if p.CycleShortHand.I != nil {
row = append(row, *p.Codename.S)
} else if p.Codename.I != nil {
h := "Codename"
exist := header.isHeaderExist(h)
if !exist {
header.Row = append(header.Row, h)
}
row = append(row, *p.CycleShortHand.I)
row = append(row, *p.Codename.I)
}
if p.EOL.S != nil {
eol, err := setColorDate(*p.EOL.S)
Expand Down Expand Up @@ -176,15 +175,13 @@ func createContentList(cycles api.CycleList) (*tableContenet, error) {
}
if p.Discontinued.S != nil {
h := "Discontinued"
fmt.Println(h)
exist := header.isHeaderExist(h)
if !exist {
header.Row = append(header.Row, "Discontinued")
}
row = append(row, *p.Discontinued.S)
} else if p.Discontinued.B != nil {
h := "Discontinued"
fmt.Println(h)
exist := header.isHeaderExist(h)
if !exist {
header.Row = append(header.Row, "Discontinued")
Expand Down Expand Up @@ -241,12 +238,12 @@ func createContent(cycle *api.Cycle) (*tableContenet, error) {
header = append(header, "Support")
row = append(row, *cycle.Support.B)
}
if cycle.CycleShortHand.S != nil {
header = append(header, "CycleShortHand")
row = append(row, *cycle.CycleShortHand.S)
} else if cycle.CycleShortHand.I != nil {
header = append(header, "CycleShortHand")
row = append(row, *cycle.CycleShortHand.I)
if cycle.Codename.S != nil {
header = append(header, "Codename")
row = append(row, *cycle.Codename.S)
} else if cycle.Codename.I != nil {
header = append(header, "Codename")
row = append(row, *cycle.Codename.I)
}
if cycle.Discontinued.S != nil {
header = append(header, "Discontinued")
Expand Down Expand Up @@ -281,14 +278,6 @@ func (h *tableHeader) isHeaderExist(s string) bool {
return false
}

func (tcl *tableContenet) display(format string) {
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(tcl.header.Row)
t.AppendRows(tcl.rows)
t.Render()
}

func (tf *tableFormat) display(tcl *tableContenet) {
tf.table.SetOutputMirror(os.Stdout)
tf.table.AppendHeader(tcl.header.Row)
Expand Down
14 changes: 7 additions & 7 deletions pkg/commands/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestCreateContentList(t *testing.T) {
s := `[
{
"cycle": "21.04",
"cycleShortHand": "HirsuteHippo",
"codename": "HirsuteHippo",
"lts": false,
"release": "2021-04-22",
"support": "2022-01-01",
Expand All @@ -33,7 +33,7 @@ func TestCreateContentList(t *testing.T) {
},
{
"cycle": 10,
"cycleShortHand": 10,
"codename": 10,
"lts": false,
"release": "2020-10-22",
"support": true,
Expand All @@ -43,7 +43,7 @@ func TestCreateContentList(t *testing.T) {
}
]`
cl := api.CycleList{}
json.Unmarshal([]byte(s), &cl)
_ = json.Unmarshal([]byte(s), &cl)
tl, err := createContentList(cl)
if err != nil {
t.Errorf("error: %s", err)
Expand All @@ -59,15 +59,15 @@ func TestCreateContentList(t *testing.T) {
func TestCreateContent(t *testing.T) {
testCases := []string{
`{
"release": "2020-10-05",
"releaseDate": "2020-10-05",
"eol": "2025-10-05",
"latest": "3.9.5",
"link": "https://www.python.org/downloads/release/python-395/"
}`,
`{
"cycleShortHand": "HirsuteHippo",
"codename": "HirsuteHippo",
"lts": false,
"release": "2021-04-22",
"releaseDate": "2021-04-22",
"support": "2022-01-01",
"eol": "2022-01-01",
"latest": "21.04",
Expand All @@ -76,7 +76,7 @@ func TestCreateContent(t *testing.T) {
}
for i, s := range testCases {
c := api.Cycle{}
json.Unmarshal([]byte(s), &c)
_ = json.Unmarshal([]byte(s), &c)
tc, err := createContent(&c)
if err != nil {
t.Errorf("error: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ func capture(f func()) string {
w.Close()
os.Stdout = out
var buf bytes.Buffer
io.Copy(&buf, r)
_, _ = io.Copy(&buf, r)
return buf.String()
}

0 comments on commit 17c0ba7

Please sign in to comment.