Skip to content

Commit

Permalink
Fixes CI to run unit tests (#42)
Browse files Browse the repository at this point in the history
* Fixes CI to run unit tests

* uses yml instead of yaml file extension

* re-adds nrf cache test

* reverts changes to nrf cache

* reverts changes to nrf cache
  • Loading branch information
gruyaume authored Dec 5, 2023
1 parent 659ba28 commit a5be567
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 31 deletions.
File renamed without changes.
17 changes: 11 additions & 6 deletions .github/workflows/main.yaml → .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2023 Canonical Ltd.

name: Main workflow
name: Master workflow

on:
pull_request:
branches:
- main
- master
push:
branches:
- main
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Unit tests
run: go test

- name: Build
run: go build

unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Unit tests
run: go test ./...
2 changes: 1 addition & 1 deletion context/management_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func nnrfNFManagementCondition(nf *models.NfProfile, nfprofile models.NfProfile)
factory.NrfConfig.Configuration.NfKeepAliveTime = 60
}
nf.HeartBeatTimer = factory.NrfConfig.Configuration.NfKeepAliveTime
logger.ManagementLog.Infoln("HearBeat Timer value: %v sec", nf.HeartBeatTimer)
logger.ManagementLog.Infof("HearBeat Timer value: %v sec", nf.HeartBeatTimer)

// PlmnList
if nfprofile.PlmnList != nil {
Expand Down
6 changes: 3 additions & 3 deletions nrfcache/match_filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func MatchSmfProfile(profile *models.NfProfile, opts *Nnrf_NFDiscovery.SearchNFI
var snssai models.Snssai
err := json.Unmarshal([]byte(reqSnssai), &snssai)
if err != nil {
logger.UtilLog.Errorf("Error Unmarshaling nssai : ", err)
logger.UtilLog.Errorf("Error Unmarshaling nssai : %+v", err)
return false, err
}

Expand Down Expand Up @@ -162,7 +162,7 @@ func MatchAmfProfile(profile *models.NfProfile, opts *Nnrf_NFDiscovery.SearchNFI
err := json.Unmarshal([]byte(targetPlmn), &plmn)

if err != nil {
logger.UtilLog.Errorf("Error Unmarshaling plmn : ", err)
logger.UtilLog.Errorf("Error Unmarshaling plmn : %+v", err)
return false, err
}

Expand Down Expand Up @@ -190,7 +190,7 @@ func MatchAmfProfile(profile *models.NfProfile, opts *Nnrf_NFDiscovery.SearchNFI
err := json.Unmarshal([]byte(guami), &guamiOpt)

if err != nil {
logger.UtilLog.Errorf("Error Unmarshaling guami : ", err)
logger.UtilLog.Errorf("Error Unmarshaling guami : %+v", err)
return false, err
}

Expand Down
43 changes: 22 additions & 21 deletions producer/nf_producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,53 @@ func init() {
factory.InitConfigFactory("../nrfTest/nrfcfg.yaml")
}

func (db *MockMongoDBClient) RestfulAPIGetOne(collName string, filter bson.M) map[string]interface{} {
func (db *MockMongoDBClient) RestfulAPIGetOne(collName string, filter bson.M) (map[string]interface{}, error) {
fmt.Println("Called Mock RestfulAPIGetOne")
return nil
return nil, nil
}

func (db *MockMongoDBClient) RestfulAPIGetMany(collName string, filter bson.M) []map[string]interface{} {
func (db *MockMongoDBClient) RestfulAPIGetMany(collName string, filter bson.M) ([]map[string]interface{}, error) {
fmt.Println("Called Mock RestfulAPIGetMany")
return nil
return nil, nil
}
func (db *MockMongoDBClient) PutOneWithTimeout(collName string, filter bson.M, putData map[string]interface{}, timeout int32, timeField string) bool {
fmt.Println("Called Mock PutOneWithTimeout")
return true
}
func (db *MockMongoDBClient) RestfulAPIPutOne(collName string, filter bson.M, putData map[string]interface{}) bool {
func (db *MockMongoDBClient) RestfulAPIPutOne(collName string, filter bson.M, putData map[string]interface{}) (bool, error) {
fmt.Println("Called Mock RestfulAPIPutOne")
return true
return true, nil
}
func (db *MockMongoDBClient) RestfulAPIPutOneNotUpdate(collName string, filter bson.M, putData map[string]interface{}) bool {
func (db *MockMongoDBClient) RestfulAPIPutOneNotUpdate(collName string, filter bson.M, putData map[string]interface{}) (bool, error) {
fmt.Println("Called Mock RestfulAPIPutOneNotUpdate")
return true
return true, nil
}
func (db *MockMongoDBClient) RestfulAPIPutMany(collName string, filterArray []bson.M, putDataArray []map[string]interface{}) bool {
func (db *MockMongoDBClient) RestfulAPIPutMany(collName string, filterArray []bson.M, putDataArray []map[string]interface{}) error {
fmt.Println("Called Mock RestfulAPIPutMany")
return true
return nil
}
func (db *MockMongoDBClient) RestfulAPIDeleteOne(collName string, filter bson.M) {
func (db *MockMongoDBClient) RestfulAPIDeleteOne(collName string, filter bson.M) error {
fmt.Println("Called Mock RestfulAPIDeleteOne")
return nil
}
func (db *MockMongoDBClient) RestfulAPIDeleteMany(collName string, filter bson.M) {
func (db *MockMongoDBClient) RestfulAPIDeleteMany(collName string, filter bson.M) error {
fmt.Println("Called Mock RestfulAPIDeleteMany")
return nil
}
func (db *MockMongoDBClient) RestfulAPIMergePatch(collName string, filter bson.M, patchData map[string]interface{}) bool {
func (db *MockMongoDBClient) RestfulAPIMergePatch(collName string, filter bson.M, patchData map[string]interface{}) error {
fmt.Println("Called Mock RestfulAPIMergePatch")
return true
return nil
}
func (db *MockMongoDBClient) RestfulAPIJSONPatch(collName string, filter bson.M, patchJSON []byte) bool {
fmt.Println("Called Mock RestfulAPIJSONPatch")
return true
func (db *MockMongoDBClient) RestfulAPIJSONPatch(collName string, filter bson.M, patchJSON []byte) error {
return nil
}
func (db *MockMongoDBClient) RestfulAPIJSONPatchExtend(collName string, filter bson.M, patchJSON []byte, dataName string) bool {
func (db *MockMongoDBClient) RestfulAPIJSONPatchExtend(collName string, filter bson.M, patchJSON []byte, dataName string) error {
fmt.Println("Called Mock RestfulAPIJSONPatchExtend")
return true
return nil
}
func (db *MockMongoDBClient) RestfulAPIPost(collName string, filter bson.M, postData map[string]interface{}) bool {
func (db *MockMongoDBClient) RestfulAPIPost(collName string, filter bson.M, postData map[string]interface{}) (bool, error) {
fmt.Println("Called Mock RestfulAPIPost")
return true
return true, nil
}
func (db *MockMongoDBClient) RestfulAPIPostMany(collName string, filter bson.M, postDataArray []interface{}) bool {
fmt.Println("Called Mock RestfulAPIPost")
Expand Down

0 comments on commit a5be567

Please sign in to comment.