Skip to content

Add tests for ddevapp package - #85

Merged
beeradb merged 24 commits into
ddev:masterfrom
beeradb:ddevapp-tests
Mar 28, 2017
Merged

beeradb merged 24 commits into
ddev:masterfrom
beeradb:ddevapp-tests

Conversation

@beeradb

@beeradb beeradb commented Mar 22, 2017 •

Copy link
Copy Markdown
Contributor

The Problem:

We need tests for the appconfig package. This is a work in progress, just opening for automation. A better writeup will be writen once we get closer to merge time.

Automation Overview:

This entire PR is automation. As an overview, you should review the changes to thetestcommon package as well as config_test.go.

Coverage numbers for the ddevapp package:

ok  	github.com/drud/ddev/pkg/ddevapp	0.011s
go tool cover -func=coverage.out
github.com/drud/ddev/pkg/ddevapp/config.go:47:	NewConfig			100.0%
github.com/drud/ddev/pkg/ddevapp/config.go:72:	Write				72.7%
github.com/drud/ddev/pkg/ddevapp/config.go:95:	Read				87.5%
github.com/drud/ddev/pkg/ddevapp/config.go:113:	Config				89.5%
github.com/drud/ddev/pkg/ddevapp/config.go:156:	DockerComposeYAMLPath		100.0%
github.com/drud/ddev/pkg/ddevapp/config.go:161:	Hostname			100.0%
github.com/drud/ddev/pkg/ddevapp/config.go:166:	WriteDockerComposeConfig	90.0%
github.com/drud/ddev/pkg/ddevapp/config.go:187:	RenderComposeYAML		88.9%
github.com/drud/ddev/pkg/ddevapp/config.go:206:	docrootPrompt			100.0%
github.com/drud/ddev/pkg/ddevapp/config.go:228:	ConfigExists			66.7%
github.com/drud/ddev/pkg/ddevapp/config.go:236:	appTypePrompt			77.8%
github.com/drud/ddev/pkg/ddevapp/config.go:273:	setInputScanner			100.0%
github.com/drud/ddev/pkg/ddevapp/config.go:278:	getInput			83.3%
github.com/drud/ddev/pkg/ddevapp/config.go:292:	isAllowedAppType		100.0%
github.com/drud/ddev/pkg/ddevapp/config.go:302:	prepDDevDirectory		83.3%
github.com/drud/ddev/pkg/ddevapp/config.go:320:	determineAppType		75.0%
total:						(statements)			86.7%

Related Issue Link(s):

#27

@beeradb

beeradb commented Mar 23, 2017

Copy link
Copy Markdown
Contributor Author

👍 this is now ready for review.

beeradb added 21 commits March 27, 2017 15:54

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I didn't give this my heart and soul, but added a couple of comments for recommendations, pretty simple things to add. Thanks for this, and for the good thinking behind it. Another step forward.

Comment thread pkg/ddevapp/config.go
f, err := os.Create(c.DockerComposeYAMLPath())
if err != nil {
log.Fatal(err)
return err

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I liked the fatal before, although it could use more context. But it seems like this is going nowhere if the docker-compose path can't be created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree that in most cases this should be a fatal. That being said, I believe it's improper for the package to do the fatal. Rather, the caller should receive in error back and have to determine what to do with it. In this case, the CLI should be the one deciding this is a fatal error, imho.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In this case then we at least have to stop right there and return the err. Currently it gets overwritten as the function continues on its merry way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Looking at the code. I see the caller (in the local package) is not handling this error. It should.

I believe this line is correct, but we absolutely need to make sure supporting code is on the same page.

Comment thread pkg/ddevapp/config.go
}

// SetInputScanner allows you to override the default input scanner with your own.
func setInputScanner(scanner *bufio.Scanner) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Congrats on this.

Comment thread pkg/ddevapp/config_test.go Outdated
}
}

// TestPrepDirectory ensures the configuraion directory can be created with the correct permissions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor typo - "configuraion"

Comment thread pkg/ddevapp/config_test.go Outdated
// Create a docroot folder.
err := os.Mkdir(filepath.Join(testDir, "docroot"), 0644)
if err != nil {
t.Skip("Could not create docroot directory under %s", testDir)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd be more in favor of a full fail in this case... ???

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably wise. In practice this should never happen, but probably better just to fail loudly if it does.

@tannerjfco

Copy link
Copy Markdown
Contributor

LGTM 👍

beeradb added 2 commits March 28, 2017 10:42
…o caller if we cannot write docker-compose. Fix typos. Error if we cannot create a docroot folder in config tests
@beeradb
beeradb merged commit 13c2dd1 into ddev:master Mar 28, 2017
@beeradb

beeradb commented Mar 28, 2017

Copy link
Copy Markdown
Contributor Author

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants