mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 09:37:02 +00:00
chore: fix many cosmetic linter warnings (#486)
* fix whitespace warnings Signed-off-by: James Hillyerd <james@hillyerd.com> * fix a number of typos Signed-off-by: James Hillyerd <james@hillyerd.com> * fix many cosmetic linter warnings Signed-off-by: James Hillyerd <james@hillyerd.com> --------- Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
@@ -70,7 +70,7 @@ func outputMbox(headers []*client.MessageHeader) error {
|
||||
for _, h := range headers {
|
||||
source, err := h.GetSource()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Get source REST failed: %v", err)
|
||||
return fmt.Errorf("get source REST failed: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("From %s\n", h.From)
|
||||
|
||||
@@ -51,7 +51,7 @@ func (n *mbNaming) Decode(v string) error {
|
||||
case "domain":
|
||||
*n = DomainNaming
|
||||
default:
|
||||
return fmt.Errorf("Unknown MailboxNaming strategy: %q", v)
|
||||
return fmt.Errorf("unknown MailboxNaming strategy: %q", v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func (eb *AsyncEventBroker[E]) AsyncTestListener(name string, capacity int) func
|
||||
return &event, nil
|
||||
|
||||
case <-time.After(time.Second * 2):
|
||||
return nil, errors.New("Timeout waiting for event")
|
||||
return nil, errors.New("timeout waiting for event")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ type Host struct {
|
||||
//
|
||||
// After-events allow extensions to take an action after an event has completed. These events are
|
||||
// processed asynchronously with respect to the rest of Inbuckets operation. However, an event
|
||||
// listener will not be called until the one before it complets.
|
||||
// listener will not be called until the one before it completes.
|
||||
type Events struct {
|
||||
AfterMessageDeleted AsyncEventBroker[event.MessageMetadata]
|
||||
AfterMessageStored AsyncEventBroker[event.MessageMetadata]
|
||||
|
||||
@@ -110,7 +110,7 @@ func (s *StoreManager) Deliver(
|
||||
|
||||
// Deliver to each mailbox.
|
||||
for _, mb := range inbound.Mailboxes {
|
||||
// Append recipient and timestamp to generated Recieved header.
|
||||
// Append recipient and timestamp to generated Received header.
|
||||
recvd := fmt.Sprintf("%s for <%s>; %s\r\n", recvdHeader, mb, tstamp)
|
||||
|
||||
// Deliver message.
|
||||
|
||||
@@ -352,7 +352,7 @@ func TestDeliverBeforeAndAfterMessageStoredEvents(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Confirm mailbox names overriden by Before were sent to After event. Order is
|
||||
// Confirm mailbox names overridden by `Before` were sent to `After` event. Order is
|
||||
// not guaranteed.
|
||||
got1, err := listener()
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -37,7 +37,7 @@ func (a *Addressing) ExtractMailbox(address string) (string, error) {
|
||||
}
|
||||
|
||||
if a.Config.MailboxNaming != config.FullNaming {
|
||||
return "", fmt.Errorf("Unknown MailboxNaming value: %v", a.Config.MailboxNaming)
|
||||
return "", fmt.Errorf("unknown MailboxNaming value: %v", a.Config.MailboxNaming)
|
||||
}
|
||||
|
||||
if domain == "" {
|
||||
|
||||
@@ -33,7 +33,6 @@ func TestShouldAcceptDomain(t *testing.T) {
|
||||
if got != tc.want {
|
||||
t.Errorf("Got %v for %q, want: %v", got, tc.domain, tc.want)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
// Test with default reject.
|
||||
@@ -60,7 +59,6 @@ func TestShouldAcceptDomain(t *testing.T) {
|
||||
if got != tc.want {
|
||||
t.Errorf("Got %v for %q, want: %v", got, tc.domain, tc.want)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -90,7 +88,6 @@ func TestShouldStoreDomain(t *testing.T) {
|
||||
if got != tc.want {
|
||||
t.Errorf("Got store %v for %q, want: %v", got, tc.domain, tc.want)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
// Test with storage disabled.
|
||||
@@ -117,7 +114,6 @@ func TestShouldStoreDomain(t *testing.T) {
|
||||
if got != tc.want {
|
||||
t.Errorf("Got store %v for %q, want: %v", got, tc.domain, tc.want)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,16 +65,16 @@ func TestDoTable(t *testing.T) {
|
||||
uri string
|
||||
wantMethod string
|
||||
base *url.URL
|
||||
wantUrl string
|
||||
wantURL string
|
||||
wantBody []byte
|
||||
}{
|
||||
{method: "GET", wantMethod: "GET", uri: "/doget", base: baseURL, wantUrl: baseURLStr + "/doget", wantBody: []byte("Test body 1")},
|
||||
{method: "POST", wantMethod: "POST", uri: "/dopost", base: baseURL, wantUrl: baseURLStr + "/dopost", wantBody: []byte("Test body 2")},
|
||||
{method: "GET", wantMethod: "GET", uri: "/doget", base: baseURLPath, wantUrl: baseURLPathStr + "/doget", wantBody: []byte("Test body 3")},
|
||||
{method: "POST", wantMethod: "POST", uri: "/dopost", base: baseURLPath, wantUrl: baseURLPathStr + "/dopost", wantBody: []byte("Test body 4")},
|
||||
{method: "GET", wantMethod: "GET", uri: "/doget", base: baseURL, wantURL: baseURLStr + "/doget", wantBody: []byte("Test body 1")},
|
||||
{method: "POST", wantMethod: "POST", uri: "/dopost", base: baseURL, wantURL: baseURLStr + "/dopost", wantBody: []byte("Test body 2")},
|
||||
{method: "GET", wantMethod: "GET", uri: "/doget", base: baseURLPath, wantURL: baseURLPathStr + "/doget", wantBody: []byte("Test body 3")},
|
||||
{method: "POST", wantMethod: "POST", uri: "/dopost", base: baseURLPath, wantURL: baseURLPathStr + "/dopost", wantBody: []byte("Test body 4")},
|
||||
}
|
||||
for _, test := range tests {
|
||||
testname := fmt.Sprintf("%s,%s", test.method, test.wantUrl)
|
||||
testname := fmt.Sprintf("%s,%s", test.method, test.wantURL)
|
||||
t.Run(testname, func(t *testing.T) {
|
||||
mth := &mockHTTPClient{}
|
||||
c := &restClient{mth, test.base}
|
||||
@@ -85,8 +85,8 @@ func TestDoTable(t *testing.T) {
|
||||
if mth.req.Method != test.wantMethod {
|
||||
t.Errorf("req.Method == %q, want %q", mth.req.Method, test.wantMethod)
|
||||
}
|
||||
if mth.req.URL.String() != test.wantUrl {
|
||||
t.Errorf("req.URL == %q, want %q", mth.req.URL.String(), test.wantUrl)
|
||||
if mth.req.URL.String() != test.wantURL {
|
||||
t.Errorf("req.URL == %q, want %q", mth.req.URL.String(), test.wantURL)
|
||||
}
|
||||
if !bytes.Equal(mth.ReqBody(), test.wantBody) {
|
||||
t.Errorf("req.Body == %q, want %q", mth.ReqBody(), test.wantBody)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package rest
|
||||
|
||||
import "github.com/gorilla/mux"
|
||||
import "github.com/inbucket/inbucket/v3/pkg/server/web"
|
||||
import (
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/inbucket/inbucket/v3/pkg/server/web"
|
||||
)
|
||||
|
||||
// SetupRoutes populates the routes for the REST interface
|
||||
func SetupRoutes(r *mux.Router) {
|
||||
|
||||
@@ -463,7 +463,7 @@ func (s *Session) transactionHandler(cmd string, args []string) {
|
||||
s.processDeletes()
|
||||
s.enterState(QUIT)
|
||||
case "NOOP":
|
||||
s.send("+OK I have sucessfully done nothing")
|
||||
s.send("+OK I have successfully done nothing")
|
||||
case "RSET":
|
||||
// Reset session, don't actually delete anything I told you to
|
||||
s.logger.Debug().Msgf("Resetting session state on RSET request")
|
||||
|
||||
@@ -206,7 +206,7 @@ func (s *Server) startSession(id int, conn net.Conn, logger zerolog.Logger) {
|
||||
ssn.send("252 Cannot VRFY user, but will accept message")
|
||||
continue
|
||||
case "NOOP":
|
||||
ssn.send("250 I have sucessfully done nothing")
|
||||
ssn.send("250 I have successfully done nothing")
|
||||
continue
|
||||
case "RSET":
|
||||
// Reset session
|
||||
|
||||
@@ -222,7 +222,6 @@ func TestReadyStateRejectedDomains(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Test invalid commands in READY state.
|
||||
@@ -255,7 +254,6 @@ func TestReadyStateInvalidCommands(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Test commands in MAIL state
|
||||
@@ -562,7 +560,6 @@ func TestBeforeMailAcceptedEventResponse(t *testing.T) {
|
||||
assert.NotNil(t, gotEvent, "BeforeMailListener did not receive Address")
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// net.Pipe does not implement deadlines
|
||||
|
||||
@@ -51,11 +51,7 @@ type Server struct {
|
||||
}
|
||||
|
||||
// NewServer sets up things for unit tests or the Start() method.
|
||||
func NewServer(
|
||||
conf *config.Root,
|
||||
mm message.Manager,
|
||||
mh *msghub.Hub) *Server {
|
||||
|
||||
func NewServer(conf *config.Root, mm message.Manager, mh *msghub.Hub) *Server {
|
||||
rootConfig = conf
|
||||
|
||||
// NewContext() will use this DataStore for the web handlers.
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
// access in most cases without requiring an infinite number of mutexes.
|
||||
type HashLock [4096]sync.RWMutex
|
||||
|
||||
// Get returns a RWMutex based on the first 12 bits of the mailbox hash. Hash must be a hexidecimal
|
||||
// Get returns a RWMutex based on the first 12 bits of the mailbox hash. Hash must be a hexadecimal
|
||||
// string of three or more characters.
|
||||
func (h *HashLock) Get(hash string) *sync.RWMutex {
|
||||
if len(hash) < 3 {
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestHashLock(t *testing.T) {
|
||||
t.Run(ts, func(t *testing.T) {
|
||||
l := hl.Get(ts)
|
||||
if l == nil {
|
||||
t.Errorf("Expeced non-nil lock for hex string %q", ts)
|
||||
t.Errorf("Expected non-nil lock for hex string %q", ts)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ type mbox struct {
|
||||
|
||||
var _ storage.Store = &Store{}
|
||||
|
||||
// New returns an emtpy memory store.
|
||||
// New returns an empty memory store.
|
||||
func New(cfg config.Storage, extHost *extension.Host) (storage.Store, error) {
|
||||
s := &Store{
|
||||
boxes: make(map[string]*mbox),
|
||||
|
||||
@@ -95,11 +95,9 @@ func MatchWithWildcards(p string, s string) bool {
|
||||
if runePattern[j-1] == '*' {
|
||||
isMatchingMatrix[0][j] = isMatchingMatrix[0][j-1]
|
||||
}
|
||||
|
||||
}
|
||||
for i := 1; i <= lenInput; i++ {
|
||||
for j := 1; j <= lenPattern; j++ {
|
||||
|
||||
if runePattern[j-1] == '*' {
|
||||
isMatchingMatrix[i][j] = isMatchingMatrix[i-1][j] || isMatchingMatrix[i][j-1]
|
||||
}
|
||||
|
||||
@@ -30,5 +30,4 @@ func TestSanitizeStyle(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user