Esempio n. 1
0
func assertDeepEqualController(c1, c2 *controller) {
	if c1 == nil || c2 == nil {
		if c1 != c2 {
			log.Error.Panicf(
				"One of the controllers is equal to nil while another is not: %#v != %#v.", c1, c2,
			)
		}
		return
	}
	if filepath.Base(c1.File) != filepath.Base(c2.File) {
		log.Error.Panicf("Controllers are from different files: %s != %s.", c1.File, c2.File)
	}
	if !r.DeepEqual(c1.Comments, c2.Comments) {
		log.Error.Panicf("Controllers have different comments: %#v != %#v.", c1.Comments, c2.Comments)
	}
	if !r.DeepEqual(c1.Parents, c2.Parents) {
		log.Error.Panicf("Controllers have different parent controllers: %#v != %#v.", c1.Parents, c2.Parents)
	}
	log.Trace.Println("Actions...")
	if err := reflect.AssertEqualFuncs(c1.Actions, c2.Actions); err != nil {
		log.Error.Panic(err)
	}
	log.Trace.Println("Before...")
	if err := reflect.AssertEqualFunc(c1.Before, c2.Before); err != nil {
		log.Error.Panic(err)
	}
	log.Trace.Println("After...")
	if err := reflect.AssertEqualFunc(c1.After, c2.After); err != nil {
		log.Error.Panic(err)
	}
	log.Trace.Println("Initially...")
	if err := reflect.AssertEqualFunc(c1.Initially, c2.Initially); err != nil {
		log.Error.Panic(err)
	}
	log.Trace.Println("Finally...")
	if err := reflect.AssertEqualFunc(c1.Finally, c2.Finally); err != nil {
		log.Error.Panic(err)
	}
}
Esempio n. 2
0
func assertDeepEqualControllers(cs1, cs2 controllers) {
	if len(cs1.data) != len(cs2.data) {
		log.Error.Panicf(
			"controllers maps %#v and %#v have different length: %d != %d",
			cs1.data, cs2.data, len(cs1.data), len(cs2.data),
		)
	}
	if err := reflect.AssertEqualFunc(cs1.init, cs2.init); err != nil {
		log.Error.Panic(err)
	}
	for k := range cs1.data {
		c1 := cs1.data[k]
		c2 := cs2.data[k]
		assertDeepEqualController(&c1, &c2)
	}
}