Skip to content

Commit

Permalink
iter6 processing
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteDSM committed Oct 23, 2023
1 parent 3c65740 commit f51458c
Showing 1 changed file with 165 additions and 2 deletions.
167 changes: 165 additions & 2 deletions internal/handlers/urlhandlers_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package handlers

import (
"github.com/gorilla/mux"
"github.com/nabbat/23_kogorta_shotener/internal/envirements"
"github.com/nabbat/23_kogorta_shotener/internal/liblog"
urlstorage "github.com/nabbat/23_kogorta_shotener/internal/storage"
"net/http"
"reflect"
Expand Down Expand Up @@ -31,6 +33,7 @@ func TestPanicHandler(t *testing.T) {
func TestRedirectHandler_HandleRedirect(t *testing.T) {
type args struct {
storage *urlstorage.URLStorage
log liblog.Logger
}
tests := []struct {
name string
Expand All @@ -42,17 +45,58 @@ func TestRedirectHandler_HandleRedirect(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rh := &RedirectHandler{}
if got := rh.HandleRedirect(tt.args.storage); !reflect.DeepEqual(got, tt.want) {
if got := rh.HandleRedirect(tt.args.storage, tt.args.log); !reflect.DeepEqual(got, tt.want) {
t.Errorf("HandleRedirect() = %v, want %v", got, tt.want)
}
})
}
}

func TestRequestLoggingMiddleware(t *testing.T) {
type args struct {
log liblog.Logger
}
tests := []struct {
name string
args args
want mux.MiddlewareFunc
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := RequestLoggingMiddleware(tt.args.log); !reflect.DeepEqual(got, tt.want) {
t.Errorf("RequestLoggingMiddleware() = %v, want %v", got, tt.want)
}
})
}
}

func TestResponseLoggingMiddleware(t *testing.T) {
type args struct {
log liblog.Logger
}
tests := []struct {
name string
args args
want mux.MiddlewareFunc
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ResponseLoggingMiddleware(tt.args.log); !reflect.DeepEqual(got, tt.want) {
t.Errorf("ResponseLoggingMiddleware() = %v, want %v", got, tt.want)
}
})
}
}

func TestShortenURLHandler_HandleShortenURL(t *testing.T) {
type args struct {
storage *urlstorage.URLStorage
c *envirements.EnvConfig
log liblog.Logger
}
tests := []struct {
name string
Expand All @@ -64,9 +108,128 @@ func TestShortenURLHandler_HandleShortenURL(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
sh := &ShortenURLHandler{}
if got := sh.HandleShortenURL(tt.args.storage, tt.args.c); !reflect.DeepEqual(got, tt.want) {
if got := sh.HandleShortenURL(tt.args.storage, tt.args.c, tt.args.log); !reflect.DeepEqual(got, tt.want) {
t.Errorf("HandleShortenURL() = %v, want %v", got, tt.want)
}
})
}
}

func Test_responseWriterWrapper_Size(t *testing.T) {
type fields struct {
ResponseWriter http.ResponseWriter
status int
size int
}
tests := []struct {
name string
fields fields
want int
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rw := &responseWriterWrapper{
ResponseWriter: tt.fields.ResponseWriter,
status: tt.fields.status,
size: tt.fields.size,
}
if got := rw.Size(); got != tt.want {
t.Errorf("Size() = %v, want %v", got, tt.want)
}
})
}
}

func Test_responseWriterWrapper_Status(t *testing.T) {
type fields struct {
ResponseWriter http.ResponseWriter
status int
size int
}
tests := []struct {
name string
fields fields
want int
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rw := &responseWriterWrapper{
ResponseWriter: tt.fields.ResponseWriter,
status: tt.fields.status,
size: tt.fields.size,
}
if got := rw.Status(); got != tt.want {
t.Errorf("Status() = %v, want %v", got, tt.want)
}
})
}
}

func Test_responseWriterWrapper_Write(t *testing.T) {
type fields struct {
ResponseWriter http.ResponseWriter
status int
size int
}
type args struct {
b []byte
}
tests := []struct {
name string
fields fields
args args
want int
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rw := &responseWriterWrapper{
ResponseWriter: tt.fields.ResponseWriter,
status: tt.fields.status,
size: tt.fields.size,
}
got, err := rw.Write(tt.args.b)
if (err != nil) != tt.wantErr {
t.Errorf("Write() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("Write() got = %v, want %v", got, tt.want)
}
})
}
}

func Test_responseWriterWrapper_WriteHeader(t *testing.T) {
type fields struct {
ResponseWriter http.ResponseWriter
status int
size int
}
type args struct {
status int
}
tests := []struct {
name string
fields fields
args args
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rw := &responseWriterWrapper{
ResponseWriter: tt.fields.ResponseWriter,
status: tt.fields.status,
size: tt.fields.size,
}
rw.WriteHeader(tt.args.status)
})
}
}

0 comments on commit f51458c

Please sign in to comment.