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

Go test only checks main_test.go #17

Closed
fallion opened this issue Nov 3, 2020 · 9 comments · Fixed by #24
Closed

Go test only checks main_test.go #17

fallion opened this issue Nov 3, 2020 · 9 comments · Fixed by #24

Comments

@fallion
Copy link

fallion commented Nov 3, 2020

const sources = `-v ${root}/**/*.go`

Uses go test /apps/name/**/*.go However this seems to only check the main_test.go. Perhaps apps/name/... might work better.

I can help if needed.

@Narven
Copy link

Narven commented Jan 28, 2021

I think this needs to change from this:

export function runBuilder(options: BuildBuilderSchema, context: BuilderContext): Observable<BuilderOutput> {
  return from(context.getProjectMetadata(context?.target?.project)).pipe(
    map((project) => {
      const root = project.root
      const sources = `-v ${root}/**/*.go`

      return runGoCommand(context, 'test', [sources])
    }),
  )
}

to this:

export function runBuilder(options: BuildBuilderSchema, context: BuilderContext): Observable<BuilderOutput> {
  return from(context.getProjectMetadata(context?.target?.project)).pipe(
    map((project) => {
       const sources = `./... -v`; // also could include -race by default
        return runGoCommand(context, 'test', [sources], { cwd: project.root});
    }),
  )
}

@Narven
Copy link

Narven commented Jan 28, 2021

The best approach it think, it would be to allow any extra arg be passed, that would allowd to had for example -race or -cover

@Narven
Copy link

Narven commented Jan 28, 2021

@beeman let me know if you want me to PR on this

@Narven
Copy link

Narven commented Jan 29, 2021

Also forgot about this, in the workspace.json it the builder needs to change from:

"test": {
  "builder": "@nx-go/nx-go:test",
  "options": {
    "main": "apps/api/main_test.go"
  }
}

to just:

"test": {
  "builder": "@nx-go/nx-go:test"
}

@beeman
Copy link
Member

beeman commented Jan 29, 2021

@beeman let me know if you want me to PR on this

Hey @Narven - I would really appreciate a PR! I should have some time this weekend en next weekend to look at nx-go!

I'm about to start a pet project that uses Go so I'll be using this again!

@Narven
Copy link

Narven commented Feb 2, 2021

@beeman I do not have permissions to push a new branch

@fallion
Copy link
Author

fallion commented Feb 2, 2021

@Narven you can create a Pr by forking this repo and creating a branch on your fork. Then you should be able to open a PR here.

@beeman
Copy link
Member

beeman commented Feb 9, 2021

This is now fixed in version 1.3.0

@beeman beeman closed this as completed Feb 9, 2021
@beeman
Copy link
Member

beeman commented Feb 9, 2021

The best approach it think, it would be to allow any extra arg be passed, that would allowd to had for example -race or -cover

Thanks for the suggestion! These are available and enabled by default in 1.4.0.

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 a pull request may close this issue.

3 participants