Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Unreleased

## Bug Fixes
* Adds `RunPostApplyRunning`,`RunPostApplyCompleted` run status by @jose-kunnel [#1323](https://github.com/hashicorp/go-tfe/pull/1323)
* Fixes an issue where stack creation panics if no project is provided in the `StackCreateOptions` creation options structure by @arybolovlev [#1284](https://github.com/hashicorp/go-tfe/pull/1284)

## Enhancements
* Adds `CanReadStateVersions` and `CanReadVariable` fields to `WorkspacePermissions` by @jondavidjohn [#1325](https://github.com/hashicorp/go-tfe/pull/1325)
* Adds Registry Tagging support for registry modules, providers and component configurations by @mrinalirao [#1318](https://github.com/hashicorp/go-tfe/pull/1318)
* Adds `AdminSCIMGroupMappings` to support mapping teams to SCIM groups by @skj-skj [#1324](https://github.com/hashicorp/go-tfe/pull/1324)
* Adds BETA `GenerateConfigOut` field to `QueryRun` and `QueryRunCreateOptions` @mjyocca [#1327](https://github.com/hashicorp/go-tfe/pull/1327)
* Adds `RunPostApplyRunning`,`RunPostApplyCompleted` run status by @jose-kunnel [#1323](https://github.com/hashicorp/go-tfe/pull/1323)

# v1.104.0

Expand Down
2 changes: 1 addition & 1 deletion stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (s StackCreateOptions) valid() error {
return ErrRequiredName
}

if s.Project.ID == "" {
if s.Project == nil || s.Project.ID == "" {
return ErrRequiredProject
}

Expand Down
52 changes: 52 additions & 0 deletions stack_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright IBM Corp. 2018, 2025
// SPDX-License-Identifier: MPL-2.0

package tfe

import (
"testing"

"github.com/stretchr/testify/assert"
)

func Test_validStackCreateOptions(t *testing.T) {
t.Parallel()

t.Run("with empty stack name", func(t *testing.T) {
s := &StackCreateOptions{
Name: "",
}
err := s.valid()
assert.Error(t, err, ErrRequiredName.Error())
})

t.Run("with empty project option", func(t *testing.T) {
s := &StackCreateOptions{
Name: "test",
}
err := s.valid()
assert.Error(t, err, ErrRequiredProject.Error())
})

t.Run("with empty project ID", func(t *testing.T) {
s := &StackCreateOptions{
Name: "test",
Project: &Project{
ID: "",
},
}
err := s.valid()
assert.Error(t, err, ErrRequiredProject.Error())
})

t.Run("with valid options", func(t *testing.T) {
s := &StackCreateOptions{
Name: "test",
Project: &Project{
ID: "prj-test",
},
}
err := s.valid()
assert.NoError(t, err)
})
}
Loading