From d0634e60148e6ae93e6e4ca8f28cbf7c2f82b563 Mon Sep 17 00:00:00 2001 From: Rustam Gilyazov <16064414+rusq@users.noreply.github.com> Date: Thu, 22 Aug 2024 19:00:45 +1000 Subject: [PATCH] missed one --- go.mod | 4 +- go.sum | 13 ++--- rubbish_test.go | 123 +++++++++++++++++++++++++----------------------- 3 files changed, 71 insertions(+), 69 deletions(-) diff --git a/go.mod b/go.mod index 6d734d6..2b4dd13 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/rusq/aklapi go 1.22 require ( - github.com/PuerkitoBio/goquery v1.9.1 + github.com/PuerkitoBio/goquery v1.9.2 github.com/rusq/osenv/v2 v2.0.1 github.com/stretchr/testify v1.8.1 ) @@ -12,6 +12,6 @@ require ( github.com/andybalholm/cascadia v1.3.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/net v0.24.0 // indirect + golang.org/x/net v0.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 0a373a8..3ecf621 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,7 @@ -github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM= -github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ= github.com/PuerkitoBio/goquery v1.9.1 h1:mTL6XjbJTZdpfL+Gwl5U2h1l9yEkJjhmlTeV9VPW7UI= github.com/PuerkitoBio/goquery v1.9.1/go.mod h1:cW1n6TmIMDoORQU5IU/P1T3tGFunOeXEpGP2WHRwkbY= -github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA= +github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE= +github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk= github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -26,21 +25,18 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -52,7 +48,6 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= diff --git a/rubbish_test.go b/rubbish_test.go index d528e08..345bf6a 100644 --- a/rubbish_test.go +++ b/rubbish_test.go @@ -99,6 +99,71 @@ func Test_parse(t *testing.T) { } } +func TestCollectionDayDetail(t *testing.T) { + type args struct { + addr string + } + tests := []struct { + name string + testSrv *httptest.Server + args args + want *CollectionDayDetailResult + wantErr bool + }{ + {"main branch", + httptest.NewServer(testMux()), + args{addr: "xxx"}, + &CollectionDayDetailResult{ + Collections: []RubbishCollection{ + { + Day: "Tuesday 27 August", + Date: adjustYear(time.Date(0, 8, 27, 0, 0, 0, 0, defaultLoc)), + Rubbish: true, + Recycle: false, + FoodScraps: false, + }, + { + Day: "Tuesday 27 August", + Date: adjustYear(time.Date(0, 8, 27, 0, 0, 0, 0, defaultLoc)), + Rubbish: false, + Recycle: false, + FoodScraps: true, + }, + { + Day: "Tuesday 3 September", + Date: adjustYear(time.Date(0, 9, 3, 0, 0, 0, 0, defaultLoc)), + Rubbish: false, + Recycle: true, + FoodScraps: false, + }, + }, + Address: &Address{ + ACRateAccountKey: "42", + Address: "Red Square", + Suggestion: "Red Square", + }, + }, + false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + defer tt.testSrv.Close() + oldAddrURI := addrURI + oldcollectionDayURI := collectionDayURI + defer func() { addrURI = oldAddrURI; collectionDayURI = oldcollectionDayURI }() + addrURI = tt.testSrv.URL + "/addr/" + collectionDayURI = tt.testSrv.URL + "/rubbish/?an=%s" + got, err := CollectionDayDetail(tt.args.addr) + if (err != nil) != tt.wantErr { + t.Errorf("CollectionDayDetail() error = %v, wantErr %v", err, tt.wantErr) + return + } + assert.Equal(t, tt.want, got) + }) + } +} + func TestCollectionDayDetailResult_NextRubbish(t *testing.T) { type fields struct { Collections []RubbishCollection @@ -217,64 +282,6 @@ func TestRubbishCollection_parseDate(t *testing.T) { } } -func TestCollectionDayDetail(t *testing.T) { - type args struct { - addr string - } - tests := []struct { - name string - testSrv *httptest.Server - args args - want *CollectionDayDetailResult - wantErr bool - }{ - {"main branch", - httptest.NewServer(testMux()), - args{addr: "xxx"}, - &CollectionDayDetailResult{ - Collections: []RubbishCollection{ - { - Day: "Sunday 21 April", - Date: adjustYear(time.Date(0, 4, 21, 0, 0, 0, 0, defaultLoc)), - Rubbish: true, - Recycle: false, - FoodScraps: false, - }, - { - Day: "Sunday 21 April", - Date: adjustYear(time.Date(0, 4, 21, 0, 0, 0, 0, defaultLoc)), - Rubbish: false, - Recycle: true, - FoodScraps: false, - }, - }, - Address: &Address{ - ACRateAccountKey: "42", - Address: "Red Square", - Suggestion: "Red Square", - }, - }, - false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - defer tt.testSrv.Close() - oldAddrURI := addrURI - oldcollectionDayURI := collectionDayURI - defer func() { addrURI = oldAddrURI; collectionDayURI = oldcollectionDayURI }() - addrURI = tt.testSrv.URL + "/addr/" - collectionDayURI = tt.testSrv.URL + "/rubbish/?an=%s" - got, err := CollectionDayDetail(tt.args.addr) - if (err != nil) != tt.wantErr { - t.Errorf("CollectionDayDetail() error = %v, wantErr %v", err, tt.wantErr) - return - } - assert.Equal(t, tt.want, got) - }) - } -} - func testMux() http.Handler { mux := http.NewServeMux() mux.HandleFunc("/addr/", func(w http.ResponseWriter, r *http.Request) {