Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go mod tidy #294

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -285,7 +284,7 @@ var (
)

func getPluginProperties(jsonPropertiesFile string) (map[string]interface{}, error) {
pluginPropertiesJson, err := ioutil.ReadFile(jsonPropertiesFile)
pluginPropertiesJson, err := os.ReadFile(jsonPropertiesFile)
if err != nil {
fmt.Printf("Could not read %s: %s\n", filepath.Base(jsonPropertiesFile), err.Error())
return nil, err
Expand Down
9 changes: 4 additions & 5 deletions generator/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package generator

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All @@ -27,11 +26,11 @@ func TestEndToEndHTMLGenerationWhenBeforeSuiteFails(t *testing.T) {
if err != nil {
t.Errorf("Expected error to be nil. Got: %s", err.Error())
}
gotContent, err := ioutil.ReadFile(filepath.Join(reportDir, "index.html"))
gotContent, err := os.ReadFile(filepath.Join(reportDir, "index.html"))
if err != nil {
t.Errorf("Error reading generated HTML file: %s", err.Error())
}
wantContent, err := ioutil.ReadFile(filepath.Join("_testdata", "expectedE2E", "before_suite_fail.html"))
wantContent, err := os.ReadFile(filepath.Join("_testdata", "expectedE2E", "before_suite_fail.html"))
if err != nil {
t.Errorf("Error reading expected HTML file: %s", err.Error())
}
Expand Down Expand Up @@ -157,11 +156,11 @@ func cleanUp(t *testing.T, reportDir string) {

func verifyExpectedFiles(t *testing.T, suiteRes, reportDir string, expectedFiles []string) {
for _, expectedFile := range expectedFiles {
gotContent, err := ioutil.ReadFile(filepath.Join(reportDir, expectedFile))
gotContent, err := os.ReadFile(filepath.Join(reportDir, expectedFile))
if err != nil {
t.Errorf("Error reading generated HTML file: %s", err.Error())
}
wantContent, err := ioutil.ReadFile(filepath.Join("_testdata", "expectedE2E", suiteRes, expectedFile))
wantContent, err := os.ReadFile(filepath.Join("_testdata", "expectedE2E", suiteRes, expectedFile))
if err != nil {
t.Errorf("Error reading expected HTML file: %s", err.Error())
}
Expand Down
17 changes: 8 additions & 9 deletions generator/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -273,7 +272,7 @@ func minifyHTMLFiles(htmlFilePaths []string, reportsDir string) {
tmpDir := os.TempDir()
srcToDest := make(map[string]string)
for _, htmlFilePath := range htmlFilePaths {
htmlBytes, err := ioutil.ReadFile(htmlFilePath)
htmlBytes, err := os.ReadFile(htmlFilePath)
if err != nil {
logger.Warnf("Error while minifying %s", err.Error())
return
Expand All @@ -283,24 +282,24 @@ func minifyHTMLFiles(htmlFilePaths []string, reportsDir string) {
logger.Warnf("Error while minifying %s", err.Error())
return
}
tmpHTMLFile, _ := ioutil.TempFile(tmpDir, "")
tmpHTMLFile, _ := os.CreateTemp(tmpDir, "")
tmpHTMLFile.Close()
tmpHTMLFilePath := tmpHTMLFile.Name()

err = ioutil.WriteFile(tmpHTMLFilePath, htmlBytes, os.ModePerm)
err = os.WriteFile(tmpHTMLFilePath, htmlBytes, os.ModePerm)
if err != nil {
logger.Warnf("Error while writing minified file %s: %s", tmpHTMLFilePath, err.Error())
return
}
srcToDest[tmpHTMLFilePath] = htmlFilePath
}
for src, dest := range srcToDest {
minifiedBytes, err := ioutil.ReadFile(src)
minifiedBytes, err := os.ReadFile(src)
if err != nil {
logger.Warnf("Error while minifying %s", err.Error())
return
}
err = ioutil.WriteFile(dest, minifiedBytes, os.ModePerm)
err = os.WriteFile(dest, minifiedBytes, os.ModePerm)
if err != nil {
logger.Warnf("Error while writing minified file %s: %s", dest, err.Error())
return
Expand Down Expand Up @@ -373,7 +372,7 @@ func readTemplates(themePath string) {
"screenshotOfFailureEnabled": screenshotOfFailureEnabled,
}

f, err := ioutil.ReadFile(filepath.Join(getAbsThemePath(themePath), "views", "partials.tmpl"))
f, err := os.ReadFile(filepath.Join(getAbsThemePath(themePath), "views", "partials.tmpl"))
if err != nil {
logger.Fatalf(err.Error())
}
Expand Down Expand Up @@ -587,9 +586,9 @@ func copyScreenshotFiles(reportsDir string) {
for _, fileName := range screenshotFiles {
srcfp := path.Join(src, fileName)
dstfp := path.Join(reportsDir, "images", fileName)
bytes, err := ioutil.ReadFile(srcfp)
bytes, err := os.ReadFile(srcfp)
if err == nil {
err = ioutil.WriteFile(dstfp, bytes, os.ModePerm)
err = os.WriteFile(dstfp, bytes, os.ModePerm)
if err != nil {
logger.Warnf("Failed to write screenshot %s", err.Error())
}
Expand Down
6 changes: 3 additions & 3 deletions generator/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package generator

import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"strings"
"sync"
Expand Down Expand Up @@ -862,7 +862,7 @@ func (b myBuf) String() string {

func TestHTMLGeneration(t *testing.T) {
for _, test := range HTMLGenerationTests {
content, err := ioutil.ReadFile(filepath.Join("_testdata", "integration", test.expectedFile))
content, err := os.ReadFile(filepath.Join("_testdata", "integration", test.expectedFile))
if err != nil {
t.Errorf("Error reading expected HTML file: %s", err.Error())
}
Expand All @@ -884,7 +884,7 @@ func TestHTMLGeneration(t *testing.T) {
}

func TestIndexPageGeneration(t *testing.T) {
content, err := ioutil.ReadFile(filepath.Join("_testdata", "integration", "pass_index.html"))
content, err := os.ReadFile(filepath.Join("_testdata", "integration", "pass_index.html"))
if err != nil {
t.Errorf("Error reading expected HTML file: %s", err.Error())
}
Expand Down
22 changes: 16 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
module github.com/getgauge/html-report

go 1.13
go 1.21

require (
github.com/dmotylev/goproperties v0.0.0-20140630191356-7cbffbaada47 // indirect
github.com/documize/html-diff v0.0.0-20160503140253-f61c192c7796
github.com/getgauge/common v0.0.0-20190514095629-619e107433ce
github.com/getgauge/gauge-proto/go/gauge_messages v0.0.0-20240122132601-bb92eb77d703
github.com/go-check/check v0.0.0-20190902080502-41f04d3bba15 // indirect
github.com/kylelemons/godebug v1.1.0
github.com/mb0/diff v0.0.0-20131118162322-d8d9a906c24d // indirect
github.com/microcosm-cc/bluemonday v1.0.2
github.com/russross/blackfriday v1.5.2
github.com/tdewolff/minify/v2 v2.7.3
golang.org/x/net v0.20.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.32.0
)

require (
github.com/dmotylev/goproperties v0.0.0-20140630191356-7cbffbaada47 // indirect
github.com/go-check/check v0.0.0-20190902080502-41f04d3bba15 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/mb0/diff v0.0.0-20131118162322-d8d9a906c24d // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/tdewolff/parse/v2 v2.4.2 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
)
Loading