github.com/sdboyer/gps@v0.16.3/manifest_test.go (about)

     1  package gps
     2  
     3  import "testing"
     4  
     5  // Test that prep manifest sanitizes manifests appropriately
     6  func TestPrepManifest(t *testing.T) {
     7  	m := SimpleManifest{
     8  		Deps: ProjectConstraints{
     9  			ProjectRoot("foo"): ProjectProperties{},
    10  			ProjectRoot("bar"): ProjectProperties{
    11  				Source: "whatever",
    12  			},
    13  		},
    14  		TestDeps: ProjectConstraints{
    15  			ProjectRoot("baz"): ProjectProperties{},
    16  			ProjectRoot("qux"): ProjectProperties{
    17  				Source: "whatever",
    18  			},
    19  		},
    20  	}
    21  
    22  	prepped := prepManifest(m)
    23  	d := prepped.DependencyConstraints()
    24  	td := prepped.TestDependencyConstraints()
    25  	if len(d) != 1 {
    26  		t.Error("prepManifest did not eliminate empty ProjectProperties from deps map")
    27  	}
    28  	if len(td) != 1 {
    29  		t.Error("prepManifest did not eliminate empty ProjectProperties from test deps map")
    30  	}
    31  
    32  	if d[ProjectRoot("bar")].Constraint != any {
    33  		t.Error("prepManifest did not normalize nil constraint to anyConstraint in deps map")
    34  	}
    35  	if td[ProjectRoot("qux")].Constraint != any {
    36  		t.Error("prepManifest did not normalize nil constraint to anyConstraint in test deps map")
    37  	}
    38  }