Skip to content

Commit

Permalink
comments and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
deniseli committed Jun 5, 2024
1 parent 39598a8 commit 56b2b5b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/ftl/cmd_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var scaffoldFuncs = template.FuncMap{
func updateGitIgnore(dir string) error {
gitRoot, ok := internal.GitRoot(dir).Get()
if !ok {
gitRoot = ""
return nil
}
f, err := os.OpenFile(path.Join(gitRoot, ".gitignore"), os.O_RDWR|os.O_CREATE, 0644) //nolint:gosec
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion common/configuration/projectconfig_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

func TestSet(t *testing.T) {
defaultPath, ok := projectconfig.GetDefaultConfigPath().Get()
defaultPath, ok := projectconfig.DefaultConfigPath().Get()
assert.True(t, ok)
origConfigBytes, err := os.ReadFile(defaultPath)
assert.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions common/projectconfig/projectconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func ConfigPaths(input []string) []string {
if len(input) > 0 {
return input
}
path, ok := GetDefaultConfigPath().Get()
path, ok := DefaultConfigPath().Get()
if !ok {
return []string{}
}
Expand All @@ -55,7 +55,7 @@ func ConfigPaths(input []string) []string {
return []string{path}
}

func GetDefaultConfigPath() optional.Option[string] {
func DefaultConfigPath() optional.Option[string] {
gitRoot, ok := internal.GitRoot("").Get()
if !ok {
return optional.None[string]()
Expand All @@ -67,7 +67,7 @@ func GetDefaultConfigPath() optional.Option[string] {
// does not already exist.
func CreateDefaultFileIfNonexistent(ctx context.Context) error {
logger := log.FromContext(ctx)
path, ok := GetDefaultConfigPath().Get()
path, ok := DefaultConfigPath().Get()
if !ok {
logger.Warnf("Failed to find Git root, so cannot verify whether an ftl-project.toml file exists there")
return nil
Expand Down
9 changes: 9 additions & 0 deletions integration/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ func Scaffold(src, dest string, tmplCtx any) Action {
}
}

// GitInit calls git init on the working directory.
func GitInit() Action {
return func(t testing.TB, ic TestContext) {
Infof("Running `git init` on the working directory: %s", ic.workDir)
err := ftlexec.Command(ic, log.Debug, ic.workDir, "git", "init", ic.workDir).RunBuffered(ic)
assert.NoError(t, err)
}
}

// Copy a module from the testdata directory to the working directory.
//
// Ensures that replace directives are correctly handled.
Expand Down
3 changes: 2 additions & 1 deletion integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ func TestRuntimeReflection(t *testing.T) {
}

func TestModuleUnitTests(t *testing.T) {
Run(t, "",
Run(t, "wrapped/ftl-project.toml",
GitInit(),
CopyModule("time"),
CopyModule("wrapped"),
CopyModule("verbtypes"),
Expand Down

0 comments on commit 56b2b5b

Please sign in to comment.