From 0ccc26697fc124bef54be5dc0dcb9ab4516ac54b Mon Sep 17 00:00:00 2001 From: connero <88785126+conneroisu@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:41:29 -0500 Subject: [PATCH 1/3] refactor static object into own files similar to file name --- Makefile | 6 +-- Taskfile.yaml | 4 ++ decoder_test.go | 6 ++- internal/errors/selection.go | 18 +++++++-- internal/errors/selection_test.go | 13 ++++--- internal/errors/selector.go | 26 ++++++++++--- parse_test.go | 30 ++++++++++++--- reflect_test.go | 56 ++++++++++++++++++++++----- scripts/makefile.fmt.sh | 2 +- scripts/taskfile.fmt.sh | 2 +- test/unit_test.go | 14 ++++--- testdata/ab_num_table.go | 22 +++++++++++ testdata/numbered_table.go | 34 +++++++++++++++++ testdata/static.go | 56 --------------------------- testdata/supernova.go | 63 +++++++++++++++++++++++++++++++ 15 files changed, 253 insertions(+), 99 deletions(-) create mode 100644 testdata/ab_num_table.go create mode 100644 testdata/numbered_table.go delete mode 100644 testdata/static.go create mode 100644 testdata/supernova.go diff --git a/Makefile b/Makefile index be8aa3bf1..cacb6da9d 100644 --- a/Makefile +++ b/Makefile @@ -26,9 +26,9 @@ lint: test: @+sh ./scripts/makefile.test.sh -.PHONY: dev.requirements -dev.requirements: - @sh ./scripts/makefile.dev.requirements.sh +.PHONY: install +install: + @sh ./scripts/makefile.install.sh .PHONY: clean clean: diff --git a/Taskfile.yaml b/Taskfile.yaml index 3c954fdc5..6a207d557 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -1,6 +1,10 @@ version: '3' tasks: + run: + cmds: + - task install + clean: cmds: - sh ./scripts/makefile.clean.sh diff --git a/decoder_test.go b/decoder_test.go index 4bcb30caf..090c6b451 100644 --- a/decoder_test.go +++ b/decoder_test.go @@ -126,7 +126,11 @@ func TestDecoder_Decode(t *testing.T) { } if len(result) != len(tc.expected) { - t.Errorf("Expected %d results, but got %d", len(tc.expected), len(result)) + t.Errorf( + "Expected %d results, but got %d", + len(tc.expected), + len(result), + ) } for i, expected := range tc.expected { diff --git a/internal/errors/selection.go b/internal/errors/selection.go index 7575c7a46..c3202f57d 100644 --- a/internal/errors/selection.go +++ b/internal/errors/selection.go @@ -23,7 +23,10 @@ type SelectionNotFound[T any] struct { // not found. // // It is used by the HeaderNotFoundError struct. -func selectionStructHighlight[T any](structPtr *T, selector string) (string, error) { +func selectionStructHighlight[T any]( + structPtr *T, + selector string, +) (string, error) { val := reflect.ValueOf(structPtr) if val.Kind() != reflect.Ptr || val.Elem().Kind() != reflect.Struct { return "", fmt.Errorf("expected struct pointer, got %s", val.Kind()) @@ -38,9 +41,14 @@ func selectionStructHighlight[T any](structPtr *T, selector string) (string, err fieldValue := val.Field(i) skv, err := genStructKeyString(field, selector) if err != nil { - return "", fmt.Errorf("failed to generate struct key string: %w", err) + return "", fmt.Errorf( + "failed to generate struct key string: %w", + err, + ) } - _, err = result.WriteString(fmt.Sprintf("\t%s %v %s\n", field.Name, fieldValue.Type(), *skv)) + _, err = result.WriteString( + fmt.Sprintf("\t%s %v %s\n", field.Name, fieldValue.Type(), *skv), + ) if err != nil { return "", fmt.Errorf("failed to write string: %w", err) } @@ -71,7 +79,9 @@ func genStructKeyString( key := match[1] value := match[2] if strings.Contains(value, highlightSelector) { - _, err = result.WriteString(fmt.Sprintf(" %s:%s", key, "==\""+value+"\"==")) + _, err = result.WriteString( + fmt.Sprintf(" %s:%s", key, "==\""+value+"\"=="), + ) if err != nil { return nil, fmt.Errorf("failed to write string: %w", err) } diff --git a/internal/errors/selection_test.go b/internal/errors/selection_test.go index a20c4d154..4c76e0f98 100644 --- a/internal/errors/selection_test.go +++ b/internal/errors/selection_test.go @@ -12,16 +12,19 @@ import ( // SuperNovaStruct is a test struct type SuperNovaStruct struct { Supernova string `json:"Supernova" seltabl:"Supernova" hSel:"tr:nth-child(1) th:nth-child(1)" dSel:"tr td:nth-child(1)" cSel:"$text"` - Year string `json:"Year" seltabl:"Year" hSel:"tr:nth-child(1) th:nth-child(2)" dSel:"tr td:nth-child(2)" cSel:"$text"` - Type string `json:"Type" seltabl:"Type" hSel:"tr:nth-child(1) th:nth-child(3)" dSel:"tr td:nth-child(3)" cSel:"$text"` - Distance string `seltabl:"Distance" hSel:"tr:nth-child(1) th:nth-child(4)" dSel:"tr td:nth-child(4)" json:"Distance" ` - Notes string `json:"Notes" seltabl:"Notes" hSel:"tr:nth-child(1) th:nth-child(5)" dSel:"tr td:nth-child(5)"` + Year string `json:"Year" seltabl:"Year" hSel:"tr:nth-child(1) th:nth-child(2)" dSel:"tr td:nth-child(2)" cSel:"$text"` + Type string `json:"Type" seltabl:"Type" hSel:"tr:nth-child(1) th:nth-child(3)" dSel:"tr td:nth-child(3)" cSel:"$text"` + Distance string `json:"Distance" seltabl:"Distance" hSel:"tr:nth-child(1) th:nth-child(4)" dSel:"tr td:nth-child(4)"` + Notes string `json:"Notes" seltabl:"Notes" hSel:"tr:nth-child(1) th:nth-child(5)" dSel:"tr td:nth-child(5)"` } // TestStructErrors tests the errors in the package func TestStructErrors(t *testing.T) { stc := SuperNovaStruct{} - output, err := selectionStructHighlight(&stc, "tr:nth-child(1) th:nth-child(1)") + output, err := selectionStructHighlight( + &stc, + "tr:nth-child(1) th:nth-child(1)", + ) assert.Nil(t, err) assert.NotEmpty(t, output) assert.True(t, strings.Contains(output, "Supernova")) diff --git a/internal/errors/selector.go b/internal/errors/selector.go index 5ec443b13..8d87ee862 100644 --- a/internal/errors/selector.go +++ b/internal/errors/selector.go @@ -23,7 +23,10 @@ type SelectorNotFound[T any] struct { // not found. // // It is used by the HeaderNotFoundError struct. -func selectorStructHighlight[T any](structPtr T, selector string) (string, error) { +func selectorStructHighlight[T any]( + structPtr T, + selector string, +) (string, error) { val := reflect.ValueOf(structPtr) if val.Kind() != reflect.Ptr || val.Elem().Kind() != reflect.Struct { return "", fmt.Errorf("expected struct pointer, got %s", val.Kind()) @@ -38,9 +41,14 @@ func selectorStructHighlight[T any](structPtr T, selector string) (string, error fieldValue := val.Field(i) skv, err := GenStructTagString(field, selector) if err != nil { - return "", fmt.Errorf("failed to generate struct tag string: %w", err) + return "", fmt.Errorf( + "failed to generate struct tag string: %w", + err, + ) } - result.WriteString(fmt.Sprintf("\t%s %v %s\n", field.Name, fieldValue.Type(), *skv)) + result.WriteString( + fmt.Sprintf("\t%s %v %s\n", field.Name, fieldValue.Type(), *skv), + ) } _, err := result.WriteString("}") if err != nil { @@ -54,7 +62,10 @@ func selectorStructHighlight[T any](structPtr T, selector string) (string, error // for a struct field. // // It is used by the HeaderNotFoundError struct. -func GenStructTagString(field reflect.StructField, highlightSelector string) (*string, error) { +func GenStructTagString( + field reflect.StructField, + highlightSelector string, +) (*string, error) { var result strings.Builder var err error result.WriteString("`") @@ -66,7 +77,9 @@ func GenStructTagString(field reflect.StructField, highlightSelector string) (*s key := match[1] value := match[2] if strings.Contains(value, highlightSelector) { - _, err = result.WriteString(fmt.Sprintf(" %s:%s", key, "==\""+value+"==\"")) + _, err = result.WriteString( + fmt.Sprintf(" %s:%s", key, "==\""+value+"==\""), + ) if err != nil { return nil, fmt.Errorf("failed to write struct tag: %w", err) } @@ -89,7 +102,8 @@ func GenStructTagString(field reflect.StructField, highlightSelector string) (*s func (e *SelectorNotFound[T]) Error() string { structString, err := selectorStructHighlight(e.Struct, e.Selector) if err != nil { - return fmt.Errorf("failed to generate struct string while reporting that a selector was not found: %w", err).Error() + return fmt.Errorf("failed to generate struct string while reporting that a selector was not found: %w", err). + Error() } return fmt.Sprintf( "selector %s not found for field %s\n%s", diff --git a/parse_test.go b/parse_test.go index 3c03d4189..d13148a5b 100644 --- a/parse_test.go +++ b/parse_test.go @@ -47,11 +47,17 @@ func TestNewFromString(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - doc, err := goquery.NewDocumentFromReader(strings.NewReader(tt.args.htmlInput)) + doc, err := goquery.NewDocumentFromReader( + strings.NewReader(tt.args.htmlInput), + ) assert.Nil(t, err) got, err := New[testdata.SuperNovaStruct](doc) if (err != nil) != tt.wantErr { - t.Errorf("NewFromString() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf( + "NewFromString() error = %v, wantErr %v", + err, + tt.wantErr, + ) return } if tt.wantErr { @@ -98,11 +104,17 @@ func TestNewFromString(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - doc, err := goquery.NewDocumentFromReader(strings.NewReader(tt.args.htmlInput)) + doc, err := goquery.NewDocumentFromReader( + strings.NewReader(tt.args.htmlInput), + ) assert.Nil(t, err) got, err := New[testdata.NumberedStruct](doc) if (err != nil) != tt.wantErr { - t.Errorf("NewFromString() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf( + "NewFromString() error = %v, wantErr %v", + err, + tt.wantErr, + ) return } if tt.wantErr { @@ -149,11 +161,17 @@ func TestNewFromString(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - doc, err := goquery.NewDocumentFromReader(strings.NewReader(tt.args.htmlInput)) + doc, err := goquery.NewDocumentFromReader( + strings.NewReader(tt.args.htmlInput), + ) assert.Nil(t, err) got, err := New[testdata.FixtureStruct](doc) if (err != nil) != tt.wantErr { - t.Errorf("NewFromString() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf( + "NewFromString() error = %v, wantErr %v", + err, + tt.wantErr, + ) return } if tt.wantErr { diff --git a/reflect_test.go b/reflect_test.go index 55504fbe5..9b0251a23 100644 --- a/reflect_test.go +++ b/reflect_test.go @@ -379,20 +379,38 @@ func TestSetStructField(t *testing.T) { t.Run(tt.name, func(t *testing.T) { tt := tt t.Parallel() - doc, err := goquery.NewDocumentFromReader(strings.NewReader(tt.cellHTML)) + doc, err := goquery.NewDocumentFromReader( + strings.NewReader(tt.cellHTML), + ) if err != nil { t.Fatalf("failed to create document: %v", err) } cellValue := doc.Find("div") - err = SetStructField(tt.structPtr, tt.fieldName, cellValue, tt.selector) + err = SetStructField( + tt.structPtr, + tt.fieldName, + cellValue, + tt.selector, + ) if (err != nil) != tt.wantErr { - t.Errorf("SetStructField() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf( + "SetStructField() error = %v, wantErr %v", + err, + tt.wantErr, + ) return } if err == nil { - v := reflect.ValueOf(tt.structPtr).Elem().FieldByName(tt.fieldName).Interface() + v := reflect.ValueOf(tt.structPtr). + Elem(). + FieldByName(tt.fieldName). + Interface() if !reflect.DeepEqual(v, tt.expected) { - t.Errorf("SetStructField() = %v, expected %v", v, tt.expected) + t.Errorf( + "SetStructField() = %v, expected %v", + v, + tt.expected, + ) } } }) @@ -683,20 +701,38 @@ func BenchSetStructField(t *testing.B) { for _, tt := range Benchs { t.Run(tt.name, func(t *testing.B) { tt := tt - doc, err := goquery.NewDocumentFromReader(strings.NewReader(tt.cellHTML)) + doc, err := goquery.NewDocumentFromReader( + strings.NewReader(tt.cellHTML), + ) if err != nil { t.Fatalf("failed to create document: %v", err) } cellValue := doc.Find("div") - err = SetStructField(tt.structPtr, tt.fieldName, cellValue, tt.selector) + err = SetStructField( + tt.structPtr, + tt.fieldName, + cellValue, + tt.selector, + ) if (err != nil) != tt.wantErr { - t.Errorf("SetStructField() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf( + "SetStructField() error = %v, wantErr %v", + err, + tt.wantErr, + ) return } if err == nil { - v := reflect.ValueOf(tt.structPtr).Elem().FieldByName(tt.fieldName).Interface() + v := reflect.ValueOf(tt.structPtr). + Elem(). + FieldByName(tt.fieldName). + Interface() if !reflect.DeepEqual(v, tt.expected) { - t.Errorf("SetStructField() = %v, expected %v", v, tt.expected) + t.Errorf( + "SetStructField() = %v, expected %v", + v, + tt.expected, + ) } } }) diff --git a/scripts/makefile.fmt.sh b/scripts/makefile.fmt.sh index a0f2aae13..390ac4e95 100644 --- a/scripts/makefile.fmt.sh +++ b/scripts/makefile.fmt.sh @@ -8,4 +8,4 @@ gofmt -w . -goline -w --max-len=79 . +golines -w --max-len=79 . diff --git a/scripts/taskfile.fmt.sh b/scripts/taskfile.fmt.sh index 059f6d105..f99891d7f 100644 --- a/scripts/taskfile.fmt.sh +++ b/scripts/taskfile.fmt.sh @@ -10,4 +10,4 @@ gum spin --spinner dot --title "Formatting Go Files with 'go fmt' in ." --show-o gofmt -w . gum spin --spinner dot --title "Formatting Go Files with 'golines' in ." --show-output -- \ - goline -w --max-len=79 . + golines -w --max-len=79 . diff --git a/test/unit_test.go b/test/unit_test.go index 22fc88856..80b9b3f48 100644 --- a/test/unit_test.go +++ b/test/unit_test.go @@ -199,10 +199,12 @@ func TestNewFromURLWithRandomData(t *testing.T) { // httpTestServer sets up a test HTTP server func httpTestServer(t *testing.T, body string) *httptest.Server { - return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, err := w.Write([]byte(body)) - if err != nil { - t.Fatalf("Failed to write response: %v", err) - } - })) + return httptest.NewServer( + http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + _, err := w.Write([]byte(body)) + if err != nil { + t.Fatalf("Failed to write response: %v", err) + } + }), + ) } diff --git a/testdata/ab_num_table.go b/testdata/ab_num_table.go new file mode 100644 index 000000000..0f6cd9d4d --- /dev/null +++ b/testdata/ab_num_table.go @@ -0,0 +1,22 @@ +package testdata + +import ( + _ "embed" +) + +// FixtureStruct is a test struct +type FixtureStruct struct { + A string `json:"a" seltabl:"a" hSel:"tr:nth-child(1) td:nth-child(1)" dSel:"tr td:nth-child(1)" cSel:"$text"` + B string `json:"b" seltabl:"b" hSel:"tr:nth-child(1) td:nth-child(2)" dSel:"tr td:nth-child(2)" cSel:"$text"` +} + +//go:embed ab_num_table.html +var FixtureABNumTable string + +// FixtureABNumTableResult is the expected result of parsing the ab_num_table +var FixtureABNumTableResult = []FixtureStruct{ + {A: "1", B: "2"}, + {A: "3", B: "4"}, + {A: "5", B: "6"}, + {A: "7", B: "8"}, +} diff --git a/testdata/numbered_table.go b/testdata/numbered_table.go new file mode 100644 index 000000000..be625783e --- /dev/null +++ b/testdata/numbered_table.go @@ -0,0 +1,34 @@ +package testdata + +import ( + _ "embed" +) + +// NumberedStruct is a test struct +type NumberedStruct struct { + Header1 string `json:"Header 1" seltabl:"Header 1" hSel:"tr:nth-child(1) td:nth-child(1)" dSel:"tr td:nth-child(1)" cSel:"$text"` + Header2 string `json:"Header 2" seltabl:"Header 2" hSel:"tr:nth-child(1) td:nth-child(2)" dSel:"tr td:nth-child(2)" cSel:"$text"` + Header3 string `json:"Header 3" seltabl:"Header 3" hSel:"tr:nth-child(1) td:nth-child(3)" dSel:"tr td:nth-child(3)" cSel:"$text"` +} + +//go:embed numbered_table.html +var NumberedTable string + +// NumberedTableResult is the expected result of parsing the numbered table +var NumberedTableResult = []NumberedStruct{ + { + Header1: "Row 1, Cell 1", + Header2: "Row 1, Cell 2", + Header3: "Row 1, Cell 3", + }, + { + Header1: "Row 2, Cell 1", + Header2: "Row 2, Cell 2", + Header3: "Row 2, Cell 3", + }, + { + Header1: "Row 3, Cell 1", + Header2: "Row 3, Cell 2", + Header3: "Row 3, Cell 3", + }, +} diff --git a/testdata/static.go b/testdata/static.go deleted file mode 100644 index 257a4040a..000000000 --- a/testdata/static.go +++ /dev/null @@ -1,56 +0,0 @@ -package testdata - -import ( - _ "embed" -) - -type FixtureStruct struct { - A string `json:"a" seltabl:"a" hSel:"tr:nth-child(1) td:nth-child(1)" dSel:"tr td:nth-child(1)" cSel:"$text"` - B string `json:"b" seltabl:"b" hSel:"tr:nth-child(1) td:nth-child(2)" dSel:"tr td:nth-child(2)" cSel:"$text"` -} - -//go:embed ab_num_table.html -var FixtureABNumTable string - -var FixtureABNumTableResult = []FixtureStruct{ - {A: "1", B: "2"}, - {A: "3", B: "4"}, - {A: "5", B: "6"}, - {A: "7", B: "8"}, -} - -type NumberedStruct struct { - Header1 string `json:"Header 1" seltabl:"Header 1" hSel:"tr:nth-child(1) td:nth-child(1)" dSel:"tr td:nth-child(1)" cSel:"$text"` - Header2 string `json:"Header 2" seltabl:"Header 2" hSel:"tr:nth-child(1) td:nth-child(2)" dSel:"tr td:nth-child(2)" cSel:"$text"` - Header3 string `json:"Header 3" seltabl:"Header 3" hSel:"tr:nth-child(1) td:nth-child(3)" dSel:"tr td:nth-child(3)" cSel:"$text"` -} - -//go:embed numbered_table.html -var NumberedTable string - -var NumberedTableResult = []NumberedStruct{ - {Header1: "Row 1, Cell 1", Header2: "Row 1, Cell 2", Header3: "Row 1, Cell 3"}, - {Header1: "Row 2, Cell 1", Header2: "Row 2, Cell 2", Header3: "Row 2, Cell 3"}, - {Header1: "Row 3, Cell 1", Header2: "Row 3, Cell 2", Header3: "Row 3, Cell 3"}, -} - -type SuperNovaStruct struct { - Supernova string `json:"Supernova" seltabl:"Supernova" hSel:"tr:nth-child(1) th:nth-child(1)" dSel:"tr td:nth-child(1)" cSel:"$text"` - Year string `json:"Year" seltabl:"Year" hSel:"tr:nth-child(1) th:nth-child(2)" dSel:"tr td:nth-child(2)" cSel:"$text"` - Type string `json:"Type" seltabl:"Type" hSel:"tr:nth-child(1) th:nth-child(3)" dSel:"tr td:nth-child(3)" cSel:"$text"` - Distance string `seltabl:"Distance" hSel:"tr:nth-child(1) th:nth-child(4)" dSel:"tr td:nth-child(4)" json:"Distance" ` - Notes string `json:"Notes" seltabl:"Notes" hSel:"tr:nth-child(1) th:nth-child(5)" dSel:"tr td:nth-child(5)"` -} - -//go:embed supernova.html -var SuperNovaTable string - -// SuperNovaTableResult is the expected result of parsing the supernova table -var SuperNovaTableResult = []SuperNovaStruct{ - {Supernova: "SN 1006", Year: "1006", Type: "Type Ia", Distance: "7,200", Notes: "Brightest recorded supernova in history"}, - {Supernova: "SN 1054 (Crab Nebula)", Year: "1054", Type: "Type II", Distance: "6,500", Notes: "Formed the Crab Nebula and pulsar"}, - {Supernova: "SN 1572 (Tycho's Supernova)", Year: "1572", Type: "Type Ia", Distance: "8,000-10,000", Notes: "Observed by Tycho Brahe"}, - {Supernova: "SN 1604 (Kepler's Supernova)", Year: "1604", Type: "Type Ia", Distance: "20,000", Notes: "Last observed supernova in the Milky Way"}, - {Supernova: "SN 1987A", Year: "1987", Type: "Type II", Distance: "168,000", Notes: "Closest observed supernova since 1604"}, - {Supernova: "SN 1993J", Year: "1993", Type: "Type IIb", Distance: "11,000,000", Notes: "In the galaxy M81"}, -} diff --git a/testdata/supernova.go b/testdata/supernova.go new file mode 100644 index 000000000..24dd50df9 --- /dev/null +++ b/testdata/supernova.go @@ -0,0 +1,63 @@ +package testdata + +import ( + _ "embed" +) + +// SuperNovaStruct is a test struct +type SuperNovaStruct struct { + Supernova string `json:"Supernova" seltabl:"Supernova" hSel:"tr:nth-child(1) th:nth-child(1)" dSel:"tr td:nth-child(1)" cSel:"$text"` + Year string `json:"Year" seltabl:"Year" hSel:"tr:nth-child(1) th:nth-child(2)" dSel:"tr td:nth-child(2)" cSel:"$text"` + Type string `json:"Type" seltabl:"Type" hSel:"tr:nth-child(1) th:nth-child(3)" dSel:"tr td:nth-child(3)" cSel:"$text"` + Distance string `json:"Distance" seltabl:"Distance" hSel:"tr:nth-child(1) th:nth-child(4)" dSel:"tr td:nth-child(4)"` + Notes string `json:"Notes" seltabl:"Notes" hSel:"tr:nth-child(1) th:nth-child(5)" dSel:"tr td:nth-child(5)"` +} + +//go:embed supernova.html +var SuperNovaTable string + +// SuperNovaTableResult is the expected result of parsing the supernova table +var SuperNovaTableResult = []SuperNovaStruct{ + { + Supernova: "SN 1006", + Year: "1006", + Type: "Type Ia", + Distance: "7,200", + Notes: "Brightest recorded supernova in history", + }, + { + Supernova: "SN 1054 (Crab Nebula)", + Year: "1054", + Type: "Type II", + Distance: "6,500", + Notes: "Formed the Crab Nebula and pulsar", + }, + { + Supernova: "SN 1572 (Tycho's Supernova)", + Year: "1572", + Type: "Type Ia", + Distance: "8,000-10,000", + Notes: "Observed by Tycho Brahe", + }, + { + Supernova: "SN 1604 (Kepler's Supernova)", + Year: "1604", + Type: "Type Ia", + Distance: "20,000", + Notes: "Last observed supernova in the Milky Way", + }, + { + Supernova: "SN 1987A", + Year: "1987", + Type: "Type II", + Distance: "168,000", + Notes: "Closest observed supernova since 1604", + }, + { + Supernova: "SN 1993J", + Year: "1993", + Type: "Type IIb", + Distance: "11,000,000", + Notes: "In the galaxy M81", + }, +} From d7e16096f3f8edd655b2505776eb4382b5c5d01b Mon Sep 17 00:00:00 2001 From: connero <88785126+conneroisu@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:42:32 -0500 Subject: [PATCH 2/3] refine the test workflow --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 965c0f29e..22f7cbbe7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,4 +1,4 @@ -name: Go +name: Test Go on: push: From 59f11c63b95adc839e9d7ae5bc642ad1f001e927 Mon Sep 17 00:00:00 2001 From: connero <88785126+conneroisu@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:45:10 -0500 Subject: [PATCH 3/3] fix taskfile script names --- Taskfile.yaml | 14 +++++++------- scripts/taskfile.test.sh | 6 ++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 6a207d557..0293fa0c7 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -7,28 +7,28 @@ tasks: clean: cmds: - - sh ./scripts/makefile.clean.sh + - sh ./scripts/taskfile.clean.sh fmt: cmds: - - sh ./scripts/makefile.fmt.sh + - sh ./scripts/taskfile.fmt.sh lint: cmds: - - sh ./scripts/makefile.lint.sh + - sh ./scripts/taskfile.lint.sh test: cmds: - - sh ./scripts/makefile.test.sh + - sh ./scripts/taskfile.test.sh database: cmds: - - sh ./scripts/makefile.database.sh + - sh ./scripts/taskfile.database.sh coverage: cmds: - - sh ./scripts/makefile.coverage.sh + - sh ./scripts/taskfile.coverage.sh install: cmds: - - sh ./scripts/makefile.install.sh + - sh ./scripts/taskfile.install.sh diff --git a/scripts/taskfile.test.sh b/scripts/taskfile.test.sh index 38b472f05..ae68e6291 100644 --- a/scripts/taskfile.test.sh +++ b/scripts/taskfile.test.sh @@ -1,6 +1,6 @@ #!/bin/bash -# file: makefile.test.sh -# url: https://github.com/conneroisu/seltabl/scripts/makefile.test.sh +# file: taskfile.test.sh +# url: https://github.com/conneroisu/blob/main/seltabl/scripts/taskfile.test.sh # title: Test Script # description: This script runs the test for the project. # @@ -11,3 +11,5 @@ gum spin --spinner dot --title "Running Tests" --show-output -- \ gum spin --spinner dot --title "Generating Coverage" --show-output -- \ go test -coverprofile=coverage.out ./... + +gocovsh coverage.out