Skip to content

Commit

Permalink
fix(buf): set correct prefix for api (#4198)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Jun 21, 2024
1 parent b5ae39a commit 1316d69
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- [#4091](https://github.com/ignite/cli/pull/4091) Fix race conditions in the plugin logic
- [#4128](https://github.com/ignite/cli/pull/4128) Check for duplicate proto fields in config
- [#4184](https://github.com/ignite/cli/pull/4184) Set custom `InitChainer` because of manually registered modules
- [#4198](https://github.com/ignite/cli/pull/4198) Set correct prefix overwriting in `buf.gen.pulsar.yaml`

## [`v28.4.0`](https://github.com/ignite/cli/releases/tag/v28.4.0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ version: v1
managed:
enabled: true
go_package_prefix:
default: cosmossdk.io/api
default: <%= ModulePath %>/api
except:
- buf.build/googleapis/googleapis
- buf.build/cosmos/gogo-proto
- buf.build/cosmos/cosmos-proto
override:
buf.build/cosmos/cosmos-sdk: cosmossdk.io/api
plugins:
- name: go-pulsar
out: ./api
Expand Down
3 changes: 2 additions & 1 deletion ignite/templates/app/proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"os"
"path/filepath"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -13,7 +14,7 @@ func TestBufFiles(t *testing.T) {
protoDir, err := os.ReadDir("files/{{protoDir}}")
require.NoError(t, err)
for _, e := range protoDir {
want = append(want, filepath.Join("{{protoDir}}", e.Name()))
want = append(want, filepath.Join("{{protoDir}}", strings.TrimSuffix(e.Name(), ".plush")))
}

got, err := BufFiles()
Expand Down
20 changes: 20 additions & 0 deletions integration/app/cmd_proto_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package app_test
import (
"os"
"path/filepath"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -58,6 +59,25 @@ var (
}
)

// TestGenerapAppCheckBufPulsarPath tests scaffolding a new chain and checks if the buf.gen.pulsar.yaml file is correct
func TestGenerapAppCheckBufPulsarPath(t *testing.T) {
var (
env = envtest.New(t)
app = env.Scaffold("github.com/test/blog")
)

bufGenPulsarPath := filepath.Join(app.SourcePath(), "proto", "buf.gen.pulsar.yaml")
_, statErr := os.Stat(bufGenPulsarPath)
require.False(t, os.IsNotExist(statErr), "buf.gen.pulsar.yaml should be scaffolded")

result, err := os.ReadFile(bufGenPulsarPath)
require.NoError(t, err)

require.True(t, strings.Contains(string(result), "default: github.com/test/blog/api"), "buf.gen.pulsar.yaml should contain the correct api override")

app.EnsureSteady()
}

func TestChangeProtoPath(t *testing.T) {
var (
env = envtest.New(t)
Expand Down

0 comments on commit 1316d69

Please sign in to comment.