VTGare / boe-tea-go

Source image bot for Discord
MIT License
20 stars 7 forks source link

Improve test coverage in pixiv package #20

Open VTGare opened 2 years ago

VTGare commented 2 years ago

Package: https://github.com/VTGare/boe-tea-go/tree/master/artworks/pixiv

Part of "Improve test coverage" milestone. Check the milestone for more info.

TLDR: at least 50% coverage across the whole project, preferably closer to 100% in smaller packages like artwork providers.

DaniruKun commented 2 years ago

@VTGare by the way, why not use pointer receiver types for the methods? E.g. instead of

func (p Pixiv) Match(s string) (string, bool) {
...
}

do

func (p *Pixiv) Match(s string) (string, bool) {
    ...
}

this reduces copies and allows to mutate the underlying struct if needed in the future.

VTGare commented 2 years ago

@DaniruKun Good question. I don't remember exactly why I used a value receiver! I do remember that I needed it in the past for provider type matching or something similar, but now it can be changed to a pointer and it won't even break things, New() function returns a pointer everywhere anyway.

VTGare commented 2 years ago

@DaniruKun Changed in https://github.com/VTGare/boe-tea-go/commit/d42684cba242ce14b21ae57f04a9d23d92b0e60e