github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/not-internal/lang/data_test.go (about)

     1  package lang
     2  
     3  import (
     4  	"github.com/muratcelep/terraform/not-internal/addrs"
     5  	"github.com/muratcelep/terraform/not-internal/tfdiags"
     6  	"github.com/zclconf/go-cty/cty"
     7  )
     8  
     9  type dataForTests struct {
    10  	CountAttrs     map[string]cty.Value
    11  	ForEachAttrs   map[string]cty.Value
    12  	Resources      map[string]cty.Value
    13  	LocalValues    map[string]cty.Value
    14  	Modules        map[string]cty.Value
    15  	PathAttrs      map[string]cty.Value
    16  	TerraformAttrs map[string]cty.Value
    17  	InputVariables map[string]cty.Value
    18  }
    19  
    20  var _ Data = &dataForTests{}
    21  
    22  func (d *dataForTests) StaticValidateReferences(refs []*addrs.Reference, self addrs.Referenceable) tfdiags.Diagnostics {
    23  	return nil // does nothing in this stub implementation
    24  }
    25  
    26  func (d *dataForTests) GetCountAttr(addr addrs.CountAttr, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
    27  	return d.CountAttrs[addr.Name], nil
    28  }
    29  
    30  func (d *dataForTests) GetForEachAttr(addr addrs.ForEachAttr, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
    31  	return d.ForEachAttrs[addr.Name], nil
    32  }
    33  
    34  func (d *dataForTests) GetResource(addr addrs.Resource, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
    35  	return d.Resources[addr.String()], nil
    36  }
    37  
    38  func (d *dataForTests) GetInputVariable(addr addrs.InputVariable, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
    39  	return d.InputVariables[addr.Name], nil
    40  }
    41  
    42  func (d *dataForTests) GetLocalValue(addr addrs.LocalValue, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
    43  	return d.LocalValues[addr.Name], nil
    44  }
    45  
    46  func (d *dataForTests) GetModule(addr addrs.ModuleCall, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
    47  	return d.Modules[addr.String()], nil
    48  }
    49  
    50  func (d *dataForTests) GetModuleInstanceOutput(addr addrs.ModuleCallInstanceOutput, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
    51  	// This will panic if the module object does not have the requested attribute
    52  	obj := d.Modules[addr.Call.String()]
    53  	return obj.GetAttr(addr.Name), nil
    54  }
    55  
    56  func (d *dataForTests) GetPathAttr(addr addrs.PathAttr, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
    57  	return d.PathAttrs[addr.Name], nil
    58  }
    59  
    60  func (d *dataForTests) GetTerraformAttr(addr addrs.TerraformAttr, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
    61  	return d.TerraformAttrs[addr.Name], nil
    62  }