@@ -26,6 +26,7 @@ import (
2626
2727 _ "embed"
2828
29+ "github.com/go-openapi/spec"
2930 "github.com/h2non/gock"
3031 atest "github.com/linuxsuren/api-testing/pkg/testing"
3132 "github.com/linuxsuren/api-testing/pkg/util"
@@ -558,7 +559,6 @@ func TestGetSuggestedAPIs(t *testing.T) {
558559 assert .NotEmpty (t , result )
559560 method := result [0 ].Request .Method
560561 assert .Equal (t , strings .ToUpper (method ), method )
561- assert .Equal (t , "todo" , result [0 ].Request .Query ["text" ])
562562}
563563
564564func TestIsStructContent (t * testing.T ) {
@@ -589,6 +589,44 @@ func TestIsStructContent(t *testing.T) {
589589 }
590590}
591591
592+ func TestGenerateRandomValue (t * testing.T ) {
593+ tests := []struct {
594+ param spec.Parameter
595+ expected interface {}
596+ }{
597+ {
598+ param : spec.Parameter {
599+ SimpleSchema : spec.SimpleSchema {
600+ Format : "int32" ,
601+ },
602+ },
603+ expected : 101 ,
604+ }, {
605+ param : spec.Parameter {
606+ SimpleSchema : spec.SimpleSchema {
607+ Format : "boolean" ,
608+ },
609+ },
610+ expected : true ,
611+ }, {
612+ param : spec.Parameter {
613+ SimpleSchema : spec.SimpleSchema {
614+ Format : "string" ,
615+ },
616+ },
617+ expected : "random" ,
618+ },
619+ }
620+
621+ for _ , tt := range tests {
622+ result := generateRandomValue (tt .param )
623+
624+ if result != tt .expected {
625+ t .Errorf ("generateRandomValue(%v) = %v, expected %v" , tt .param , result , tt .expected )
626+ }
627+ }
628+ }
629+
592630const defaultSchemaForTest = `{"properties": {
593631 "name": {"type": "string"},
594632 "age": {"type": "integer"}
0 commit comments