Skip to content

Commit

Permalink
decoder: Update legacy tests related to Reference
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Mar 23, 2023
1 parent 9c5b6e5 commit c0a2da2
Show file tree
Hide file tree
Showing 10 changed files with 607 additions and 789 deletions.
140 changes: 60 additions & 80 deletions decoder/body_extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,8 @@ func TestCompletionAtPos_BodySchema_Extensions_Count(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"cpu_count": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
OfType: cty.Number,
},
Constraint: schema.Reference{
OfType: cty.Number,
},
},
},
Expand Down Expand Up @@ -275,10 +273,8 @@ func TestCompletionAtPos_BodySchema_Extensions_Count(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"cpu_count": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
OfType: cty.Number,
},
Constraint: schema.Reference{
OfType: cty.Number,
},
},
},
Expand Down Expand Up @@ -332,7 +328,7 @@ func TestCompletionAtPos_BodySchema_Extensions_Count(t *testing.T) {
hcl.Pos{
Line: 3,
Column: 15,
Byte: 57,
Byte: 58,
},
lang.CompleteCandidates([]lang.Candidate{
{
Expand Down Expand Up @@ -413,10 +409,8 @@ func TestCompletionAtPos_BodySchema_Extensions_Count(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"cpu_count": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
OfType: cty.Number,
},
Constraint: schema.Reference{
OfType: cty.Number,
},
},
},
Expand Down Expand Up @@ -458,10 +452,8 @@ func TestCompletionAtPos_BodySchema_Extensions_Count(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"cpu_count": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
OfType: cty.Number,
},
Constraint: schema.Reference{
OfType: cty.Number,
},
},
},
Expand Down Expand Up @@ -534,12 +526,12 @@ func TestCompletionAtPos_BodySchema_Extensions_Count(t *testing.T) {
Filename: "test.tf",
Start: hcl.Pos{
Line: 4,
Column: 16,
Column: 17,
Byte: 67,
},
End: hcl.Pos{
Line: 4,
Column: 16,
Column: 17,
Byte: 67,
},
}, NewText: "count.index", Snippet: "count.index"},
Expand Down Expand Up @@ -745,10 +737,8 @@ func TestCompletionAtPos_BodySchema_Extensions_ForEach(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"thing": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
OfType: cty.String,
},
Constraint: schema.Reference{
OfType: cty.String,
},
},
},
Expand Down Expand Up @@ -856,10 +846,8 @@ thing =
Attributes: map[string]*schema.AttributeSchema{
"thing": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
OfType: cty.String,
},
Constraint: schema.Reference{
OfType: cty.String,
},
},
},
Expand All @@ -886,10 +874,8 @@ thing =
Attributes: map[string]*schema.AttributeSchema{
"thing": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
OfType: cty.Number,
},
Constraint: schema.Reference{
OfType: cty.Number,
},
},
},
Expand Down Expand Up @@ -919,10 +905,8 @@ thing =
Attributes: map[string]*schema.AttributeSchema{
"thing": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
OfType: cty.Number,
},
Constraint: schema.Reference{
OfType: cty.Number,
},
},
},
Expand Down Expand Up @@ -978,10 +962,8 @@ for_each = {
Attributes: map[string]*schema.AttributeSchema{
"thing": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
OfType: cty.DynamicPseudoType,
},
Constraint: schema.Reference{
OfType: cty.DynamicPseudoType,
},
},
},
Expand Down Expand Up @@ -1052,8 +1034,8 @@ foo {
TextEdit: lang.TextEdit{
Range: hcl.Range{
Filename: "test.tf",
Start: hcl.Pos{Line: 7, Column: 10, Byte: 109},
End: hcl.Pos{Line: 7, Column: 10, Byte: 109},
Start: hcl.Pos{Line: 7, Column: 11, Byte: 109},
End: hcl.Pos{Line: 7, Column: 11, Byte: 109},
},
NewText: "each.key",
Snippet: "each.key",
Expand All @@ -1070,8 +1052,8 @@ foo {
TextEdit: lang.TextEdit{
Range: hcl.Range{
Filename: "test.tf",
Start: hcl.Pos{Line: 7, Column: 10, Byte: 109},
End: hcl.Pos{Line: 7, Column: 10, Byte: 109},
Start: hcl.Pos{Line: 7, Column: 11, Byte: 109},
End: hcl.Pos{Line: 7, Column: 11, Byte: 109},
},
NewText: "each.value",
Snippet: "each.value",
Expand All @@ -1094,10 +1076,8 @@ foo {
Attributes: map[string]*schema.AttributeSchema{
"thing": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
OfType: cty.String,
},
Constraint: schema.Reference{
OfType: cty.String,
},
},
},
Expand Down Expand Up @@ -1204,22 +1184,22 @@ func TestCompletionAtPos_BodySchema_Extensions_SelfRef(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"cpu_count": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
Constraint: schema.OneOf{
schema.Reference{
OfType: cty.Number,
},
schema.LiteralTypeExpr{
schema.LiteralType{
Type: cty.Number,
},
},
},
"fox": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
Constraint: schema.OneOf{
schema.Reference{
OfType: cty.Number,
},
schema.LiteralTypeExpr{
schema.LiteralType{
Type: cty.Number,
},
},
Expand Down Expand Up @@ -1276,22 +1256,22 @@ func TestCompletionAtPos_BodySchema_Extensions_SelfRef(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"cpu_count": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
Constraint: schema.OneOf{
schema.Reference{
OfType: cty.Number,
},
schema.LiteralTypeExpr{
schema.LiteralType{
Type: cty.Number,
},
},
},
"fox": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
Constraint: schema.OneOf{
schema.Reference{
OfType: cty.Number,
},
schema.LiteralTypeExpr{
schema.LiteralType{
Type: cty.Number,
},
},
Expand Down Expand Up @@ -1364,22 +1344,22 @@ func TestCompletionAtPos_BodySchema_Extensions_SelfRef(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"cpu_count": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
Constraint: schema.OneOf{
schema.Reference{
OfType: cty.Number,
},
schema.LiteralTypeExpr{
schema.LiteralType{
Type: cty.Number,
},
},
},
"fox": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
Constraint: schema.OneOf{
schema.Reference{
OfType: cty.Number,
},
schema.LiteralTypeExpr{
schema.LiteralType{
Type: cty.Number,
},
},
Expand Down Expand Up @@ -1435,11 +1415,11 @@ func TestCompletionAtPos_BodySchema_Extensions_SelfRef(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"cpu_count": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
Constraint: schema.OneOf{
schema.Reference{
OfType: cty.Number,
},
schema.LiteralTypeExpr{
schema.LiteralType{
Type: cty.Number,
},
},
Expand Down Expand Up @@ -1495,22 +1475,22 @@ func TestCompletionAtPos_BodySchema_Extensions_SelfRef(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"cpu_count": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
Constraint: schema.OneOf{
schema.Reference{
OfType: cty.Number,
},
schema.LiteralTypeExpr{
schema.LiteralType{
Type: cty.Number,
},
},
},
"fox": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
Constraint: schema.OneOf{
schema.Reference{
OfType: cty.Number,
},
schema.LiteralTypeExpr{
schema.LiteralType{
Type: cty.Number,
},
},
Expand Down Expand Up @@ -1575,11 +1555,11 @@ func TestCompletionAtPos_BodySchema_Extensions_SelfRef(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"fox": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
Constraint: schema.OneOf{
schema.Reference{
OfType: cty.Number,
},
schema.LiteralTypeExpr{
schema.LiteralType{
Type: cty.Number,
},
},
Expand All @@ -1601,11 +1581,11 @@ func TestCompletionAtPos_BodySchema_Extensions_SelfRef(t *testing.T) {
Attributes: map[string]*schema.AttributeSchema{
"cpu_count": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.TraversalExpr{
Constraint: schema.OneOf{
schema.Reference{
OfType: cty.Number,
},
schema.LiteralTypeExpr{
schema.LiteralType{
Type: cty.Number,
},
},
Expand Down
Loading

0 comments on commit c0a2da2

Please sign in to comment.