Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Increasing code coverage #56

Merged
merged 28 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
06c6c9c
Cover FTSearch
shacharPash Jan 4, 2023
d64bf36
delete IndexIndexDataType
shacharPash Jan 4, 2023
9cdcf23
add TestQueryCommandBuilder
shacharPash Jan 4, 2023
52208ee
more cover to equal & ToString of graph data types
shacharPash Jan 5, 2023
9c1d4dd
cover more equal/ToString/Hash functions
shacharPash Jan 5, 2023
6bcb7c1
fix test
shacharPash Jan 5, 2023
be145f9
fix infinity
shacharPash Jan 5, 2023
308fa09
start covering command builder
shacharPash Jan 5, 2023
b739bc9
Add TestInsertArgsError
shacharPash Jan 5, 2023
1aa6509
Cover Reducer
shacharPash Jan 8, 2023
ff1150e
Cover Document
shacharPash Jan 9, 2023
abbb0fb
Cover limit
shacharPash Jan 9, 2023
6c185d3
Delete ExplainScore
shacharPash Jan 9, 2023
4bf2f2b
Cover CuckooCommandBuilder
shacharPash Jan 9, 2023
65675f5
Cover TopK
shacharPash Jan 10, 2023
9c3fb0e
Cover Search Query
shacharPash Jan 10, 2023
6bf5c89
Cover All search Query
shacharPash Jan 10, 2023
d873cc0
Cover search schema
shacharPash Jan 10, 2023
2c1edc2
Cover FT._List
shacharPash Jan 10, 2023
b108752
mark as Comment CallProcedureReadOnly
shacharPash Jan 10, 2023
6258bab
בםצצקמא ValueToStringNoQuotes
shacharPash Jan 10, 2023
fdb4b10
cover more from AddVectorField
shacharPash Jan 10, 2023
9062cf0
More cover to timeSeries
shacharPash Jan 10, 2023
8d019d3
Comment TsDuplicatePolicy AsPolicy
shacharPash Jan 10, 2023
6e5caf8
delete unnecessary code from graph
shacharPash Jan 11, 2023
f5eae2c
Merge branch 'master' into codecov2
shacharPash Jan 11, 2023
71734a0
delete unnecessary code from search
shacharPash Jan 11, 2023
9766f27
delete unnecessary code from TimeSeries
shacharPash Jan 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/NRedisStack/Graph/DataTypes/Edge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class Edge : GraphEntity
/// <value></value>
public long Destination { get; set; }

// TODO: check if this is needed:
/// <summary>
/// Overriden from the base `Equals` implementation. In addition to the expected behavior of checking
/// reference equality, we'll also fall back and check to see if the: Source, Destination, and RelationshipType
Expand Down
20 changes: 1 addition & 19 deletions src/NRedisStack/Graph/DataTypes/GraphEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public abstract class GraphEntity

public IDictionary<string, object> PropertyMap = new Dictionary<string, object>();

// TODO: check if this is needed:
/// <summary>
/// Overriden Equals that considers the equality of the entity ID as well as the equality of the
/// properties that each entity has.
Expand Down Expand Up @@ -49,7 +48,7 @@ public override int GetHashCode()

hash = hash * 31 + Id.GetHashCode();

foreach(var prop in PropertyMap)
foreach (var prop in PropertyMap)
{
hash = hash * 31 + prop.Key.GetHashCode();
hash = hash * 31 + prop.Value.GetHashCode();
Expand All @@ -59,23 +58,6 @@ public override int GetHashCode()
}
}

/// <summary>
/// Overriden ToString that emits a string containing the ID and property map of the entity.
/// </summary>
/// <returns></returns>
public override string ToString()
{
var sb = new StringBuilder();

sb.Append("GraphEntity{id=");
sb.Append(Id);
sb.Append(", propertyMap=");
sb.Append(PropertyMap);
sb.Append('}');

return sb.ToString();
}

public string PropertyMapToString()
{
var sb = new StringBuilder();
Expand Down
1 change: 0 additions & 1 deletion src/NRedisStack/Graph/DataTypes/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public Node()
Labels = new List<string>();
}

// TODO: check if this is needed:
/// <summary>
/// Overriden member that checks to see if the names of the labels of a node are equal
/// (in addition to base `Equals` functionality).
Expand Down
2 changes: 0 additions & 2 deletions src/NRedisStack/Graph/DataTypes/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public Path(IList<Node> nodes, IList<Edge> edges)
Edges = new ReadOnlyCollection<Edge>(edges);
}

// TODO: check if this is needed:
/// <summary>
/// Overriden `Equals` method that will consider the equality of the Nodes and Edges between two paths.
/// </summary>
Expand Down Expand Up @@ -68,7 +67,6 @@ public override int GetHashCode()
}
}

// TODO: check if this is needed:
/// <summary>
/// Overridden `ToString` method that will emit a string based on the string values of the nodes and edges
/// on the path.
Expand Down
11 changes: 0 additions & 11 deletions src/NRedisStack/Graph/GraphCacheList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,4 @@ private void GetProcedureInfo()
protected virtual ResultSet CallProcedure() =>
graph.CallProcedure(GraphName, Procedure);
}

internal class ReadOnlyGraphCacheList : GraphCacheList
{
internal ReadOnlyGraphCacheList(string graphName, string procedure, GraphCommands redisGraph) :
base(graphName, procedure, redisGraph)
{
}

protected override ResultSet CallProcedure() =>
graph.CallProcedureReadOnly(GraphName, Procedure);
}
}
1 change: 0 additions & 1 deletion src/NRedisStack/Graph/GraphCommandBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using NRedisStack.Literals;
using NRedisStack.RedisStackCommands;
using static NRedisStack.Graph.RedisGraphUtilities;

namespace NRedisStack
{
Expand Down
28 changes: 1 addition & 27 deletions src/NRedisStack/Graph/GraphCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public async Task<ResultSet> RO_QueryAsync(string graphName, string query, long?
internal static readonly Dictionary<string, List<string>> EmptyKwargsDictionary =
new Dictionary<string, List<string>>();

// TODO: Check if needed
// TODO: Check if this is needed:
/// <inheritdoc/>
public ResultSet CallProcedure(string graphName, string procedure) =>
CallProcedure(graphName, procedure, Enumerable.Empty<string>(), EmptyKwargsDictionary);
Expand Down Expand Up @@ -147,32 +147,6 @@ public async Task<ResultSet> DeleteAsync(string graphName)
return processedResult;
}

// TODO: Check if this (CallProcedure) is needed
/// <inheritdoc/>
public ResultSet CallProcedureReadOnly(string graphName, string procedure) =>
CallProcedureReadOnly(graphName, procedure, Enumerable.Empty<string>(), EmptyKwargsDictionary);

/// <inheritdoc/>
public ResultSet CallProcedureReadOnly(string graphName, string procedure, IEnumerable<string> args) =>
CallProcedureReadOnly(graphName, procedure, args, EmptyKwargsDictionary);

/// <inheritdoc/>
public ResultSet CallProcedureReadOnly(string graphName, string procedure, IEnumerable<string> args, Dictionary<string, List<string>> kwargs)
{
args = args.Select(a => QuoteString(a));

var queryBody = new StringBuilder();

queryBody.Append($"CALL {procedure}({string.Join(",", args)})");

if (kwargs.TryGetValue("y", out var kwargsList))
{
queryBody.Append(string.Join(",", kwargsList));
}

return RO_Query(graphName, queryBody.ToString());
}

/// <inheritdoc/>
public IReadOnlyList<string> Explain(string graphName, string query)
{
Expand Down
3 changes: 1 addition & 2 deletions src/NRedisStack/Graph/Header.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public enum ResultSetColumnTypes
/// <summary>
/// Collection of the schema types present in the header.
/// </summary>
// [Obsolete("SchemaType is no longer supported after RedisGraph 2.1 and will always return COLUMN_SCALAR")] // TODO: it's correct?
[Obsolete("SchemaType is no longer supported after RedisGraph 2.1 and will always return COLUMN_SCALAR")]
public List<ResultSetColumnTypes> SchemaTypes { get; }

/// <summary>
Expand All @@ -41,7 +41,6 @@ internal Header(RedisResult result)
}
}

// TODO: check if this is needed:
public override bool Equals(object? obj)
{
if (obj == null) return this == null;
Expand Down
28 changes: 0 additions & 28 deletions src/NRedisStack/Graph/IGraphCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,34 +133,6 @@ public interface IGraphCommands
/// <remarks><seealso href="https://redis.io/commands/graph.delete"/></remarks>
Task<ResultSet> DeleteAsync(string graphName);

// TODO: Check if this (CallProcedure) is needed
/// <summary>
/// Call a saved procedure against a read-only node.
/// </summary>
/// <param name="graphName">The graph containing the saved procedure.</param>
/// <param name="procedure">The procedure name.</param>
/// <returns>A result set.</returns>
ResultSet CallProcedureReadOnly(string graphName, string procedure);

/// <summary>
/// Call a saved procedure with parameters against a read-only node.
/// </summary>
/// <param name="graphName">The graph containing the saved procedure.</param>
/// <param name="procedure">The procedure name.</param>
/// <param name="args">A collection of positional arguments.</param>
/// <returns>A result set.</returns>
ResultSet CallProcedureReadOnly(string graphName, string procedure, IEnumerable<string> args);

/// <summary>
/// Call a saved procedure with parameters against a read-only node.
/// </summary>
/// <param name="graphName">The graph containing the saved procedure.</param>
/// <param name="procedure">The procedure name.</param>
/// <param name="args">A collection of positional arguments.</param>
/// <param name="kwargs">A collection of keyword arguments.</param>
/// <returns>A result set.</returns>
ResultSet CallProcedureReadOnly(string graphName, string procedure, IEnumerable<string> args, Dictionary<string, List<string>> kwargs);

/// <summary>
/// Constructs a query execution plan but does not run it. Inspect this execution plan to better understand how your
/// query will get executed.
Expand Down
1 change: 0 additions & 1 deletion src/NRedisStack/Graph/Point.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public Point(List<double> values)
this.longitude = values[1];
}

// TODO: check if this is needed:
public override bool Equals(object? obj)
{
if (obj == null) return this == null;
Expand Down
1 change: 0 additions & 1 deletion src/NRedisStack/Graph/Record.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ internal Record(List<string> header, List<object> values)
/// </summary>
public int Size => Header.Count;

// TODO: check if this is needed:
public override bool Equals(object? obj)
{
if (obj == null) return this == null;
Expand Down
15 changes: 0 additions & 15 deletions src/NRedisStack/Graph/RedisGraphUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,6 @@ internal static string PrepareQuery(string query, IDictionary<string, object> pa
return preparedQuery.ToString();
}

public static string ValueToStringNoQuotes(object value)
{
if (value == null)
{
return "null";
}

if (value is IConvertible floatValue)
{
return ConvertibleToString(floatValue);
}

return value.ToString();
}

public static string ValueToString(object value)
{
if (value == null)
Expand Down
2 changes: 1 addition & 1 deletion src/NRedisStack/Json/JsonCommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static SerializedCommand ArrPop(RedisKey key, string? path = null, long?
throw new ArgumentException("index cannot be defined without path");

var args = AssembleNonNullArguments(key, path, index);
return new SerializedCommand(JSON.ARRPOP, args)!; // TODO: understand the meaning of the '!' here
return new SerializedCommand(JSON.ARRPOP, args)!;
}

public static SerializedCommand ArrTrim(RedisKey key, string path, long start, long stop) =>
Expand Down
3 changes: 0 additions & 3 deletions src/NRedisStack/Json/JsonCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ public async Task<bool> SetAsync(RedisKey key, RedisValue path, RedisValue json,
return (await _db.ExecuteAsync(JsonCommandBuilder.Set(key, path, json, when))).OKtoBoolean();
}

/// <inheritdoc/> // TODO: check way asnyc methods dont have documenation
public async Task<bool> SetFromFileAsync(RedisKey key, RedisValue path, string filePath, When when = When.Always)
{
if (!File.Exists(filePath))
Expand All @@ -262,7 +261,6 @@ public async Task<bool> SetFromFileAsync(RedisKey key, RedisValue path, string f
return await SetAsync(key, path, fileContent, when);
}

/// <inheritdoc/>
public async Task<int> SetFromDirectoryAsync(RedisValue path, string filesPath, When when = When.Always)
{
int inserted = 0;
Expand All @@ -285,7 +283,6 @@ public async Task<int> SetFromDirectoryAsync(RedisValue path, string filesPath,
return inserted;
}


public async Task<long?[]> StrAppendAsync(RedisKey key, string value, string? path = null)
{
return (await _db.ExecuteAsync(JsonCommandBuilder.StrAppend(key, value, path))).ToNullableLongArray();
Expand Down
7 changes: 3 additions & 4 deletions src/NRedisStack/Search/AggregationRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ public AggregationRequest Limit(int offset, int count)
return this;
}

public AggregationRequest Limit(int count)
{
return Limit(0, count);
}
public AggregationRequest Limit(int count) => Limit(0, count);

public AggregationRequest SortBy(string property) => SortBy(SortedField.Asc(property));

public AggregationRequest SortBy(params SortedField[] Fields)
{
Expand Down
5 changes: 3 additions & 2 deletions src/NRedisStack/Search/AggregationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ internal AggregationResult(RedisResult result, long cursorId = -1)
{
var key = (string)raw[j++];
var val = raw[j++];
if (val.Type != ResultType.MultiBulk)
cur.Add(key, (RedisValue)val);
if (val.Type == ResultType.MultiBulk)
continue; // TODO: handle multi-bulk (maybe change to object?)
cur.Add(key, (RedisValue)val);
}
_results[i - 1] = cur;
}
Expand Down
43 changes: 1 addition & 42 deletions src/NRedisStack/Search/DataTypes/InfoResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ public class InfoResult

public string IndexName => GetString("index_name");
public Dictionary<string, RedisResult> IndexOption => GetRedisResultDictionary("index_options");
public Dictionary<string, RedisResult[]> IndexDefinition => GetRedisResultsDictionary("index_definition");

// public Dictionary<string, RedisResult[]> Attributes => GetRedisResultsDictionary("attributes"); // TODO: check if this is correct
public Dictionary<string, RedisResult>[] Attributes => GetRedisResultDictionaryArray("attributes"); // TODO: check if this is correct
public Dictionary<string, RedisResult>[] Attributes => GetRedisResultDictionaryArray("attributes");


public long NumDocs => GetLong("num_docs");
Expand Down Expand Up @@ -122,25 +120,6 @@ private Dictionary<string, RedisResult> GetRedisResultDictionary(string key)
}
}

private Dictionary<string, RedisResult[]> GetRedisResultsDictionary(string key)
{
if (_all.TryGetValue(key, out var value))
{
var result = new Dictionary<string, RedisResult[]>();

foreach (RedisResult[] fv in (RedisResult[])value)
{
result.Add((string)fv[0], fv);
}

return result;
}
else
{
return default;
}
}

private Dictionary<string, RedisResult>[] GetRedisResultDictionaryArray(string key)
{
if (_all.TryGetValue(key, out var value))
Expand All @@ -165,25 +144,5 @@ private Dictionary<string, RedisResult>[] GetRedisResultDictionaryArray(string k
return default;
}
}
// private Dictionary<string, RedisResult>[] GetRedisResultsDictionaryTry(string key)
// {
// if (_all.TryGetValue(key, out var value))
// {
// var result = new List<Dictionary<string, RedisResult>>();

// int i = 0;
// foreach (RedisResult[] fv in (RedisResult[])value)
// {
// var res = GetRedisResultDictionary((string)fv[i++]);
// result.Add(res);
// }

// return result.ToArray();
// }
// else
// {
// return default;
// }
// }
}
}
34 changes: 0 additions & 34 deletions src/NRedisStack/Search/DataTypes/SearchInformation.cs

This file was deleted.

Loading