github.com/kotovmak/go-admin@v1.1.1/tests/common/common.go (about)

     1  package common
     2  
     3  import (
     4  	"fmt"
     5  	"regexp"
     6  
     7  	"github.com/gavv/httpexpect"
     8  	"github.com/kotovmak/go-admin/plugins/admin/modules/form"
     9  	"github.com/mgutz/ansi"
    10  )
    11  
    12  var reg, _ = regexp.Compile("<input type=\"hidden\" name=\"" + form.TokenKey + "\" value='(.*?)'>")
    13  
    14  // ExtraTest contains unit test sections of the GoAdmin admin plugin.
    15  func ExtraTest(e *httpexpect.Expect) {
    16  
    17  	fmt.Println()
    18  	fmt.Println("============================================")
    19  	printlnWithColor("Basic Function Black-Box Testing", "blue")
    20  	fmt.Println("============================================")
    21  	fmt.Println()
    22  
    23  	cookie := authTest(e)
    24  
    25  	// permission check
    26  	permissionTest(e, cookie)
    27  	// role check
    28  	roleTest(e, cookie)
    29  	// manager check
    30  	managerTest(e, cookie)
    31  	// api check
    32  	apiTest(e, cookie)
    33  	// menu check
    34  	menuTest(e, cookie)
    35  	// operation log check
    36  	operationLogTest(e, cookie)
    37  
    38  	// get data from outside source check
    39  	externalTest(e, cookie)
    40  	// normal table tests
    41  	normalTest(e, cookie)
    42  }
    43  
    44  // ExtraTest contains unit test sections of the GoAdmin admin plugin.
    45  func Test(e *httpexpect.Expect) {
    46  
    47  	fmt.Println()
    48  	fmt.Println("============================================")
    49  	printlnWithColor("Basic Function Black-Box Testing", "blue")
    50  	fmt.Println("============================================")
    51  	fmt.Println()
    52  
    53  	cookie := authTest(e)
    54  
    55  	// permission check
    56  	permissionTest(e, cookie)
    57  	// role check
    58  	roleTest(e, cookie)
    59  	// manager check
    60  	managerTest(e, cookie)
    61  	// menu check
    62  	menuTest(e, cookie)
    63  	// operation log check
    64  	operationLogTest(e, cookie)
    65  }
    66  
    67  func printlnWithColor(msg string, color string) {
    68  	fmt.Println(ansi.Color(msg, color))
    69  }