Skip to content

Commit

Permalink
chore: move spp to pkg/spp
Browse files Browse the repository at this point in the history
  • Loading branch information
ravisuhag committed Feb 5, 2025
1 parent 897969d commit 63a58f4
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 18 deletions.
File renamed without changes.
1 change: 0 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Test

on:
push:
branches:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion spp/apid_test.go → pkg/spp/apid_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package spp_test

import (
"github.com/ravisuhag/astro/spp"
"github.com/ravisuhag/astro/pkg/spp"
"testing"
)

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion spp/header_test.go → pkg/spp/header_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package spp_test

import (
"github.com/ravisuhag/astro/spp"
"github.com/ravisuhag/astro/pkg/spp"
"testing"
)

Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions spp/packet_test.go → pkg/spp/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package spp_test

import (
"bytes"
"github.com/ravisuhag/astro/spp"
spp2 "github.com/ravisuhag/astro/pkg/spp"
"testing"
)

func TestNewSpacePacket(t *testing.T) {
data := []byte{0x01, 0x02, 0x03}
packet, err := spp.NewSpacePacket(100, 0, data)
packet, err := spp2.NewSpacePacket(100, 0, data)
if err != nil {
t.Fatalf("Failed to create new space packet: %v", err)
}
Expand All @@ -24,7 +24,7 @@ func TestNewSpacePacket(t *testing.T) {

func TestSpacePacketEncodeDecode(t *testing.T) {
data := []byte{0x01, 0x02, 0x03}
packet, err := spp.NewSpacePacket(100, 0, data)
packet, err := spp2.NewSpacePacket(100, 0, data)
if err != nil {
t.Fatalf("Failed to create new space packet: %v", err)
}
Expand All @@ -34,7 +34,7 @@ func TestSpacePacketEncodeDecode(t *testing.T) {
t.Fatalf("Failed to encode space packet: %v", err)
}

decoded, err := spp.Decode(encoded)
decoded, err := spp2.Decode(encoded)
if err != nil {
t.Fatalf("Failed to decode space packet: %v", err)
}
Expand All @@ -50,8 +50,8 @@ func TestSpacePacketEncodeDecode(t *testing.T) {

func TestSpacePacketWithSecondaryHeader(t *testing.T) {
data := []byte{0x01, 0x02, 0x03}
secondaryHeader := spp.SecondaryHeader{Timestamp: 1234567890}
packet, err := spp.NewSpacePacket(100, 0, data, spp.WithSecondaryHeader(secondaryHeader))
secondaryHeader := spp2.SecondaryHeader{Timestamp: 1234567890}
packet, err := spp2.NewSpacePacket(100, 0, data, spp2.WithSecondaryHeader(secondaryHeader))
if err != nil {
t.Fatalf("Failed to create new space packet with secondary header: %v", err)
}
Expand All @@ -68,7 +68,7 @@ func TestSpacePacketWithSecondaryHeader(t *testing.T) {
func TestSpacePacketWithErrorControl(t *testing.T) {
data := []byte{0x01, 0x02, 0x03}
crc := uint16(0xABCD)
packet, err := spp.NewSpacePacket(100, 0, data, spp.WithErrorControl(crc))
packet, err := spp2.NewSpacePacket(100, 0, data, spp2.WithErrorControl(crc))
if err != nil {
t.Fatalf("Failed to create new space packet with error control: %v", err)
}
Expand All @@ -81,7 +81,7 @@ func TestSpacePacketWithErrorControl(t *testing.T) {
func TestSpacePacketValidate(t *testing.T) {
// Test case: Valid SpacePacket
data := []byte{0x01, 0x02, 0x03}
packet, err := spp.NewSpacePacket(100, 0, data)
packet, err := spp2.NewSpacePacket(100, 0, data)
if err != nil {
t.Fatalf("Failed to create new space packet: %v", err)
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestSpacePacketValidate(t *testing.T) {
packet.PrimaryHeader.SecondaryHeaderFlag = 0 // Reset to valid state

// Test case: Valid secondary header
secondaryHeader := spp.SecondaryHeader{Timestamp: 1234567890}
secondaryHeader := spp2.SecondaryHeader{Timestamp: 1234567890}
packet.SecondaryHeader = &secondaryHeader
packet.PrimaryHeader.SecondaryHeaderFlag = 1
if err := packet.Validate(); err != nil {
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions spp/service_test.go → pkg/spp/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ package spp_test

import (
"bytes"
"github.com/ravisuhag/astro/spp"
spp2 "github.com/ravisuhag/astro/pkg/spp"
"testing"
)

func TestWritePacket(t *testing.T) {
data := []byte{0x01, 0x02, 0x03}
packet, err := spp.NewSpacePacket(100, 0, data)
packet, err := spp2.NewSpacePacket(100, 0, data)
if err != nil {
t.Fatalf("Failed to create new space packet: %v", err)
}

var buf bytes.Buffer
err = spp.WritePacket(packet, &buf)
err = spp2.WritePacket(packet, &buf)
if err != nil {
t.Fatalf("Failed to send space packet: %v", err)
}
Expand All @@ -26,19 +26,19 @@ func TestWritePacket(t *testing.T) {

func TestSendPacket(t *testing.T) {
data := []byte{0x01, 0x02, 0x03}
packet, err := spp.NewSpacePacket(100, 0, data)
packet, err := spp2.NewSpacePacket(100, 0, data)
if err != nil {
t.Fatalf("Failed to create new space packet: %v", err)
}
var buf bytes.Buffer
err = spp.WritePacket(packet, &buf)
err = spp2.WritePacket(packet, &buf)
if err != nil {
t.Fatalf("Failed to send space packet: %v", err)
}
if buf.Len() == 0 {
t.Fatalf("Buffer is empty after sending packet")
}
receivedPacket, err := spp.ReadPacket(&buf)
receivedPacket, err := spp2.ReadPacket(&buf)
if err != nil {
t.Fatalf("Failed to receive space packet: %v", err)
}
Expand Down
File renamed without changes.

0 comments on commit 63a58f4

Please sign in to comment.