github.com/lheiskan/zebrapack@v4.1.1-0.20181107023619-e955d028f9bf+incompatible/cmd/addzid/map_test.go (about)

     1  package main
     2  
     3  import (
     4  	"testing"
     5  
     6  	cv "github.com/glycerine/goconvey/convey"
     7  )
     8  
     9  func Test910MapAddZid(t *testing.T) {
    10  
    11  	cv.Convey("Given a struct with a map , ", t, func() {
    12  		cv.Convey("with map[string]bool, then addzid to should add a zid for the map field.", func() {
    13  			in1 := "type HasMap struct {Jobid map[string]bool }"
    14  			ex1 := "package main type HasMap struct { Jobid map[string]bool `zid:\"0\"`}"
    15  			added := ExtractStringAddZid(in1)
    16  			//p("added='%v'", added)
    17  			cv.So(added, ShouldStartWithModuloWhiteSpace, ex1)
    18  		})
    19  
    20  		cv.Convey("with a more complex map, then addzid to should add a zid for the map field.", func() {
    21  			in1 := "type HasMap struct {S string  `zid:\"0\"`; Jobid map[int]map[string]Jobid }"
    22  			ex1 := "package main type HasMap struct { S string  `zid:\"0\"`\nJobid map[int]map[string]Jobid  `zid:\"1\"`}"
    23  			added := ExtractStringAddZid(in1)
    24  			//p("added='%v'", added)
    25  			cv.So(added, ShouldStartWithModuloWhiteSpace, ex1)
    26  		})
    27  
    28  	})
    29  }