|
1 | 1 | package staticnetworkconfig_test
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "bytes" |
4 | 5 | "context"
|
5 | 6 | "encoding/json"
|
6 | 7 | "fmt"
|
@@ -489,6 +490,46 @@ var _ = Describe("StaticNetworkConfig", func() {
|
489 | 490 | Expect(err).ToNot(HaveOccurred())
|
490 | 491 | Expect(formattedOutput).To(Equal(""))
|
491 | 492 | })
|
| 493 | + |
| 494 | + It("logs all NMConnection files in a consolidated format", func() { |
| 495 | + |
| 496 | + var logBuffer bytes.Buffer |
| 497 | + testLog := logrus.New() |
| 498 | + testLog.SetOutput(&logBuffer) |
| 499 | + |
| 500 | + testGenerator := snc.New(testLog, snc.Config{MinVersionForNmstateService: common.MinimalVersionForNmstatectl}) |
| 501 | + |
| 502 | + staticNetworkConfig := []*models.HostStaticNetworkConfig{ |
| 503 | + { |
| 504 | + MacInterfaceMap: models.MacInterfaceMap{ |
| 505 | + { |
| 506 | + LogicalNicName: "eth0", |
| 507 | + MacAddress: "f8:75:a4:a4:00:fe", |
| 508 | + }, |
| 509 | + { |
| 510 | + LogicalNicName: "eth1", |
| 511 | + MacAddress: "f8:75:a4:a4:00:ff", |
| 512 | + }, |
| 513 | + { |
| 514 | + LogicalNicName: "eth2", |
| 515 | + MacAddress: "f8:75:a4:a4:01:00", |
| 516 | + }, |
| 517 | + }, |
| 518 | + NetworkYaml: multipleInterfacesYAML, |
| 519 | + }, |
| 520 | + } |
| 521 | + |
| 522 | + staticNetworkConfigBytes, err := json.Marshal(staticNetworkConfig) |
| 523 | + Expect(err).NotTo(HaveOccurred()) |
| 524 | + |
| 525 | + _, err = testGenerator.GenerateStaticNetworkConfigData(context.Background(), string(staticNetworkConfigBytes)) |
| 526 | + |
| 527 | + if err == nil { |
| 528 | + logOutput := logBuffer.String() |
| 529 | + |
| 530 | + Expect(logOutput).To(ContainSubstring("Adding NMConnection files: <eth0.nmconnection>, <eth1.nmconnection>, <eth2.nmconnection>")) |
| 531 | + } |
| 532 | + }) |
492 | 533 | })
|
493 | 534 |
|
494 | 535 | var _ = Describe("StaticNetworkConfig.GenerateStaticNetworkConfigDataYAML - generate nmpolicy", func() {
|
|
0 commit comments