Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

begin to add tests for apis/storage/v1alpha #36

Merged
merged 4 commits into from
Mar 29, 2018

Conversation

ObiWahn
Copy link
Contributor

@ObiWahn ObiWahn commented Mar 8, 2018

tests for apis/storage/v1alpha part of issue #33

@ObiWahn ObiWahn added the WIP label Mar 8, 2018
@ObiWahn ObiWahn force-pushed the tests/apis-storage-v1alpha branch 3 times, most recently from e74bb38 to 9b7c610 Compare March 8, 2018 14:39
@maxkernbach maxkernbach removed the WIP label Mar 14, 2018
@ObiWahn ObiWahn force-pushed the tests/apis-storage-v1alpha branch from 9b7c610 to 8118132 Compare March 15, 2018 08:19
@ObiWahn ObiWahn force-pushed the tests/apis-storage-v1alpha branch from 8118132 to 97afe56 Compare March 15, 2018 08:28
@ObiWahn ObiWahn requested a review from ewoutp March 28, 2018 07:18
…v1alpha

* origin/master: (145 commits)
  Enable LONG on kube-arangodb-long test
  fix rocksdb_encryption_test
  fix - /api/version will answer on all servers (not leader only)
  fixes required after merge
  add downgrade tests
  add missing uniuri
  Merged in master
  Fixed unit-test packages
  Fixed unit tests
  Do not Fail the deployment, unless there is REALLY no other way
  Updated tests
  Refactor DeploymentState to DeploymentPhase
  Revert example change
  Added detection on unschedulable pods
  Detect pods not being scheduled
  Same fix on ArangoLocalStorage
  AsOwner no longer things the owner refers to a controller. It refers to the ArangoDeployment
  disable upgrade tests to 3.4 until 3.4 is available on hub.docker.com
  Listen for secret changes
  Log improvements
  ...
Copy link
Contributor

@ewoutp ewoutp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments about underscores and assert.Error.. apply to all tests.

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

func Test_LocalStorageSpec_Creation(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid the use of underscore in member names.

)

func Test_LocalStorageSpec_Creation(t *testing.T) {
var (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop this and do something like class := ... on first use


class = StorageClassSpec{"SpecName", true}
local = LocalStorageSpec{StorageClass: class, LocalPath: []string{""}}
err = local.Validate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't understand this and the next line.
Probably you want to use assert.Error or assert.NoError see https://godoc.org/github.com/stretchr/testify/assert#Error

assert.Equal(t, errors.Cause(class.Validate()), errors.Cause(err))

class = StorageClassSpec{"spec-name", true}
local = LocalStorageSpec{StorageClass: class, LocalPath: []string{""}} //is this allowed - should the paths be checked?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably indicates a bug.

assert.True(t, nil != storageClassSpec.Validate())

storageClassSpec = StorageClassSpec{Name: "TheSpecName", IsDefault: true} // no upper-case allowed
assert.True(t, nil != storageClassSpec.Validate())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert.Error

Copy link
Contributor

@ewoutp ewoutp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of small issues


class := StorageClassSpec{"SpecName", true}
local := LocalStorageSpec{StorageClass: class, LocalPath: []string{""}}
err := local.Validate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge with line 39.
assert.Error(t, local.Validate())

class = StorageClassSpec{"spec-name", true}
local = LocalStorageSpec{StorageClass: class, LocalPath: []string{}}
err = local.Validate()
assert.Equal(t, ValidationError, errors.Cause(err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert.IsTrue(t, IsValidation(err))

)

func TestArangoLocalStorageCreation(t *testing.T) {
assert.True(t, false, "test needs to be implemented")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO???


assert.Equal(t, "target", specTarget.Name)
rv := specSource.ResetImmutableFields("fieldPrefix-", &specTarget)
assert.Equal(t, "fieldPrefix-name", strings.Join(rv[:], ", "))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go: no need for rv[:], just rv is enough here

@ObiWahn ObiWahn force-pushed the tests/apis-storage-v1alpha branch 2 times, most recently from f0b34b4 to 04305ef Compare March 29, 2018 12:22
@ObiWahn ObiWahn force-pushed the tests/apis-storage-v1alpha branch from 04305ef to 8a59df6 Compare March 29, 2018 12:25

// test creation of arango local storage
func TestArangoLocalStorageCreation(t *testing.T) {
// REVIEW - is there something more meaningful to test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this is testing go and not our code.
I suggest to drop it.

Copy link
Contributor

@ewoutp ewoutp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to drop as in comment, after that merge it

@ObiWahn ObiWahn merged commit d2f685f into master Mar 29, 2018
@ObiWahn ObiWahn deleted the tests/apis-storage-v1alpha branch March 29, 2018 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants