Skip to content

Nested comparison #138

Answered by maxatome
Nvos asked this question in Q&A
Mar 18, 2021 · 2 comments · 5 replies
Discussion options

You must be logged in to vote

Smuggle can now handle maps/slices in its fields-path form, so for this specific case we can use either JSONPointer or Smuggle operators:

package main_test

import (
	"testing"

	"github.com/maxatome/go-testdeep/td"
)

var got = &UserConnection{
	Edges: []*UserEdge{ // <- I want to test structs at specific indexes in this slice
		{
			Node: &User{ // <- I want to test fields from this struct
				ID:       21474836481,
				Username: "user 1",
				Active:   true,
			},
		},
		{
			Node: &User{ // <- I want to test fields from this struct
				ID:       21474836482,
				Username: "user2",
				Active:   false,
			},
		},
	},
}

func Test(t *testing.T) {
	//
	// With JSONPointer + JSON
	td.Cmp(t, 

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@Nvos
Comment options

@maxatome
Comment options

@maxatome
Comment options

@maxatome
Comment options

@maxatome
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by maxatome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants