Repository: raviqqe/muffet
Pull request #278 (2023-01-29 11:09:02)

Remove time tracking

codecov[bot]: # [Codecov](https://codecov.io/gh/raviqqe/muffet/pull/278?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yota+Toyama) Report
> Merging [#278](https://codecov.io/gh/raviqqe/muffet/pull/278?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yota+Toyama) (31c5a20) into [main](https://codecov.io/gh/raviqqe/muffet/commit/079b9221e9988ad4e0254751d19eedf8e3db837b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yota+Toyama) (079b922) will **increase** coverage by `0.00%`.
> The diff coverage is `80.00%`.

```diff
@@           Coverage Diff           @@
##             main     #278   +/-   ##
=======================================
  Coverage   86.64%   86.64%           
=======================================
  Files          27       27           
  Lines         786      779    -7     
=======================================
- Hits          681      675    -6     
+ Misses         86       85    -1     
  Partials       19       19           
```


| [Impacted Files](https://codecov.io/gh/raviqqe/muffet/pull/278?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yota+Toyama) | Coverage Δ | |
|---|---|---|
| [page\_result.go](https://codecov.io/gh/raviqqe/muffet/pull/278?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yota+Toyama#diff-cGFnZV9yZXN1bHQuZ28=) | `100.00% <ø> (ø)` | |
| [page\_checker.go](https://codecov.io/gh/raviqqe/muffet/pull/278?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yota+Toyama#diff-cGFnZV9jaGVja2VyLmdv) | `95.08% <75.00%> (-0.31%)` | :arrow_down: |
| [xml\_page\_result.go](https://codecov.io/gh/raviqqe/muffet/pull/278?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yota+Toyama#diff-eG1sX3BhZ2VfcmVzdWx0Lmdv) | `70.00% <100.00%> (+0.30%)` | :arrow_up: |

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yota+Toyama)


Patch:
diff --git a/page_checker.go b/page_checker.go
index 6457ef0..3a724cd 100644
--- a/page_checker.go
+++ b/page_checker.go
@@ -1,9 +1,6 @@
 package main
 
-import (
-	"sync"
-	"time"
-)
+import "sync"
 
 type pageChecker struct {
 	fetcher       *linkFetcher
@@ -43,10 +40,9 @@ func (c *pageChecker) checkPage(p *page) {
 	ec := make(chan *errorLinkResult, len(us))
 	w := sync.WaitGroup{}
 
-	pageStart := time.Now()
 	for u, err := range us {
 		if err != nil {
-			ec <- &errorLinkResult{u, err, time.Since(time.Now())}
+			ec <- &errorLinkResult{u, err}
 			continue
 		}
 
@@ -55,14 +51,12 @@ func (c *pageChecker) checkPage(p *page) {
 		go func(u string) {
 			defer w.Done()
 
-			linkStart := time.Now()
 			status, p, err := c.fetcher.Fetch(u)
-			linkElapsed := time.Since(linkStart)
 
 			if err == nil {
-				sc <- &successLinkResult{u, status, linkElapsed}
+				sc <- &successLinkResult{u, status}
 			} else {
-				ec <- &errorLinkResult{u, err, linkElapsed}
+				ec <- &errorLinkResult{u, err}
 			}
 
 			if !c.onePageOnly && p != nil && c.linkValidator.Validate(p.URL()) {
@@ -72,7 +66,6 @@ func (c *pageChecker) checkPage(p *page) {
 	}
 
 	w.Wait()
-	pageElapsed := time.Since(pageStart)
 
 	close(sc)
 	close(ec)
@@ -89,7 +82,7 @@ func (c *pageChecker) checkPage(p *page) {
 		es = append(es, e)
 	}
 
-	c.results <- &pageResult{p.URL().String(), ss, es, pageElapsed}
+	c.results <- &pageResult{p.URL().String(), ss, es}
 }
 
 func (c *pageChecker) addPage(p *page) {
diff --git a/page_result.go b/page_result.go
index 9e37e33..af4b09f 100644
--- a/page_result.go
+++ b/page_result.go
@@ -1,24 +1,19 @@
 package main
 
-import "time"
-
 type pageResult struct {
 	URL                string
 	SuccessLinkResults []*successLinkResult
 	ErrorLinkResults   []*errorLinkResult
-	Elapsed            time.Duration
 }
 
 type successLinkResult struct {
 	URL        string
 	StatusCode int
-	Elapsed    time.Duration
 }
 
 type errorLinkResult struct {
-	URL     string
-	Error   error
-	Elapsed time.Duration
+	URL   string
+	Error error
 }
 
 func (r *pageResult) OK() bool {
diff --git a/xml_page_result.go b/xml_page_result.go
index 2631550..0b38a7b 100644
--- a/xml_page_result.go
+++ b/xml_page_result.go
@@ -1,18 +1,16 @@
 package main
 
 type xmlPageResult struct {
-	Url      string  `xml:"name,attr"`
-	Total    int     `xml:"tests,attr"`
-	Failures int     `xml:"failures,attr"`
-	Skipped  int     `xml:"skipped,attr"`
-	Time     float64 `xml:"time,attr"`
+	Url      string `xml:"name,attr"`
+	Total    int    `xml:"tests,attr"`
+	Failures int    `xml:"failures,attr"`
+	Skipped  int    `xml:"skipped,attr"`
 	// spell-checker: disable-next-line
 	Links []*xmlLinkResult `xml:"testcase"`
 }
 
 type xmlLinkResult struct {
-	Url  string  `xml:"name,attr"`
-	Time float64 `xml:"time,attr"`
+	Url string `xml:"name,attr"`
 	// spell-checker: disable-next-line
 	Source  string          `xml:"classname,attr"`
 	Failure *xmlLinkFailure `xml:"failure"`
@@ -31,7 +29,6 @@ func newXMLPageResult(pr *pageResult) *xmlPageResult {
 			&xmlLinkResult{
 				Url:    r.URL,
 				Source: pr.URL,
-				Time:   r.Elapsed.Seconds(),
 			},
 		)
 	}
@@ -42,15 +39,13 @@ func newXMLPageResult(pr *pageResult) *xmlPageResult {
 			&xmlLinkResult{
 				Url:     r.URL,
 				Source:  pr.URL,
-				Time:    r.Elapsed.Seconds(),
 				Failure: &xmlLinkFailure{Message: r.Error.Error()},
 			},
 		)
 	}
 
 	return &xmlPageResult{
-		Url:  pr.URL,
-		Time: pr.Elapsed.Seconds(),
+		Url: pr.URL,
 		// TODO: Consider adding information skipped links, if that can be tracked.
 		Skipped:  0,
 		Total:    len(ls),


Test patch:
diff --git a/json_page_result_test.go b/json_page_result_test.go
index a6f6e1f..2d14424 100644
--- a/json_page_result_test.go
+++ b/json_page_result_test.go
@@ -15,9 +15,8 @@ func TestMarshalErrorJSONPageResult(t *testing.T) {
 			"http://foo.com",
 			[]*successLinkResult{},
 			[]*errorLinkResult{
-				{"http://foo.com/bar", errors.New("baz"), 0},
+				{"http://foo.com/bar", errors.New("baz")},
 			},
-			0,
 		}, false))
 	assert.Nil(t, err)
 	cupaloy.SnapshotT(t, bs)
@@ -28,10 +27,9 @@ func TestMarshalSuccessJSONPageResult(t *testing.T) {
 		&pageResult{
 			"http://foo.com",
 			[]*successLinkResult{
-				{"http://foo.com/foo", 200, 0},
+				{"http://foo.com/foo", 200},
 			},
 			[]*errorLinkResult{},
-			0,
 		}, true))
 	assert.Nil(t, err)
 	cupaloy.SnapshotT(t, bs)
diff --git a/page_result_formatter_test.go b/page_result_formatter_test.go
index 907c202..c1f2121 100644
--- a/page_result_formatter_test.go
+++ b/page_result_formatter_test.go
@@ -10,7 +10,7 @@ import (
 func TestPageResultFormatterFormatEmptyResult(t *testing.T) {
 	cupaloy.SnapshotT(t,
 		newPageResultFormatter(false, true).Format(
-			&pageResult{"http://foo.com", nil, nil, 0},
+			&pageResult{"http://foo.com", nil, nil},
 		),
 	)
 }
@@ -21,10 +21,9 @@ func TestPageResultFormatterFormatSuccessLinkResults(t *testing.T) {
 			&pageResult{
 				"http://foo.com",
 				[]*successLinkResult{
-					{"http://foo.com", 200, 0},
+					{"http://foo.com", 200},
 				},
 				nil,
-				0,
 			},
 		),
 	)
@@ -36,12 +35,11 @@ func TestPageResultFormatterFormatErrorLinkResults(t *testing.T) {
 			&pageResult{
 				"http://foo.com",
 				[]*successLinkResult{
-					{"http://foo.com", 200, 0},
+					{"http://foo.com", 200},
 				},
 				[]*errorLinkResult{
-					{"http://foo.com", errors.New("500"), 0},
+					{"http://foo.com", errors.New("500")},
 				},
-				0,
 			},
 		),
 	)
@@ -53,10 +51,9 @@ func TestPageResultFormatterFormatSuccessLinkResultsVerbosely(t *testing.T) {
 			&pageResult{
 				"http://foo.com",
 				[]*successLinkResult{
-					{"http://foo.com", 200, 0},
+					{"http://foo.com", 200},
 				},
 				nil,
-				0,
 			},
 		),
 	)
@@ -68,12 +65,11 @@ func TestPageResultFormatterFormatErrorLinkResultsVerbosely(t *testing.T) {
 			&pageResult{
 				"http://foo.com",
 				[]*successLinkResult{
-					{"http://foo.com", 200, 0},
+					{"http://foo.com", 200},
 				},
 				[]*errorLinkResult{
-					{"http://foo.com", errors.New("500"), 0},
+					{"http://foo.com", errors.New("500")},
 				},
-				0,
 			},
 		),
 	)
@@ -85,11 +81,10 @@ func TestPageResultFormatterSortSuccessLinkResults(t *testing.T) {
 			&pageResult{
 				"http://foo.com",
 				[]*successLinkResult{
-					{"http://foo.com", 200, 0},
-					{"http://bar.com", 200, 0},
+					{"http://foo.com", 200},
+					{"http://bar.com", 200},
 				},
 				nil,
-				0,
 			},
 		),
 	)
@@ -102,10 +97,9 @@ func TestPageResultFormatterSortErrorLinkResults(t *testing.T) {
 				"http://foo.com",
 				nil,
 				[]*errorLinkResult{
-					{"http://foo.com", errors.New("500"), 0},
-					{"http://bar.com", errors.New("500"), 0},
+					{"http://foo.com", errors.New("500")},
+					{"http://bar.com", errors.New("500")},
 				},
-				0,
 			},
 		),
 	)
diff --git a/page_result_test.go b/page_result_test.go
index 5b36802..8767a02 100644
--- a/page_result_test.go
+++ b/page_result_test.go
@@ -7,6 +7,6 @@ import (
 )
 
 func TestPageResultOK(t *testing.T) {
-	assert.True(t, (&pageResult{"", nil, nil, 0}).OK())
-	assert.False(t, (&pageResult{"", nil, []*errorLinkResult{{}}, 0}).OK())
+	assert.True(t, (&pageResult{"", nil, nil}).OK())
+	assert.False(t, (&pageResult{"", nil, []*errorLinkResult{{}}}).OK())
 }